How to find frequency of a given data?

I have a data whose sampling freqency is 16000/s.
This is the code that I am using to find the freqency.
Is this the right way?
If there is a better way, I would like to learn that.
drate = 16000;
nr = 2^13;
delt = 1/(drate);
padd=2;
freq=zeros(1,nr*padd/2);
T=freq;
for k=1:nr*padd/2
freq(k)=(k-1)/(nr*padd*delt);
T(k)=(k-1)*delt;
end
U = Flap_w;
U = U - mean(U);
Uf=fft(U,nr*padd);
psd=zeros(1,nr*padd/2);
for l=1:nr*padd/2
psd(l)=abs((delt/nr)*(Uf(l))^2);
end
plot(freq,psd,'-b','linewidth',1.0);
xlim([0 8000]);
ylim([0 0.015]);
grid on
xlabel('$frequency (Hz)$','interpreter','latex','fontname','arial','fontsize',12);
ylabel('$PSD (a.u.)$','interpreter','latex','fontname','arial','fontsize',12);

4 Commenti

See the examples computing PSD from FFT at
doc fft
Can we use fft even if the signal data has both positive and negative values in them?
If youre simply looking for frequencies, then it makes no difference if the signal has positive or negative values, you're just looking for the rate that the signal osccilates and what other signals are present.
I got an error with your code because Flap_w isnt defined, but it might be useful for you to look at questions that are similar - finding dominant frequency in a time series data using fft
Not sure if it's helpful, but maybe you can use the code in the link above, to guide you?
E
dpb
dpb il 20 Mag 2019
And why would you think otherwise? One of the most common uses would be on such waveforms and even if weren't one generally will make it contain both by detrending and subtracting mean (DC component).
As noted, the example in the documentation has it all laid out including how normaliztion works.

Accedi per commentare.

Risposte (0)

Richiesto:

il 19 Mag 2019

Commentato:

dpb
il 20 Mag 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by