FFT issue

6 vues (au cours des 30 derniers jours)
B T
B T le 3 Mar 2012
When I attempt a Fourier Transform of my data, v, all the values of Y are NaN + NaNi
%v(t)
t=-1.5:0.001:1.5; %time, s
B=1.5*pi; %T
f0=20; %Hz
for i=1:length(t);
v(i)=(B*sin(2*pi*f0*t(i)))/(pi*t(i));
end
plot(t,v);
max(v) %Voltage,V
min(v) %Voltage,V
%Fourier Transform
Y=fft(v)
Any clues as to why this is occurring??
Thanks guys

Réponse acceptée

Walter Roberson
Walter Roberson le 3 Mar 2012
Your time range includes time 0, and your v(i) for time 0 is 0/0 which is NaN. Once you have a NaN in your data, it is going to "pollute" everything else when you do the fft()
  1 commentaire
B T
B T le 3 Mar 2012
Thank you.

Connectez-vous pour commenter.

Plus de réponses (2)

B T
B T le 3 Mar 2012
%v(t)
t=-1.5:0.001:1.5; %time, s
B=1.5*pi; %T
f0=20; %Hz
for i=1:length(t);
v(i)=(B*sin(2*pi*f0*t(i)))/(pi*t(i));
end
plot(t,v)
display('Max V')
max(v) %Voltage,V
display('Min V')
min(v) %Voltage,V
%Fourier Transform
t=(0.01*10^-15):0.001:1.5; %time, s
B=1.5*pi; %T
f0=20; %Hz
for i=1:length(t);
v1(i)=(B*sin(2*pi*f0*t(i)))/(pi*t(i));
end
Y=fftn(v1);
f=0:(20/length(Y)):19.9867;
plot(f,Y)
So I am now getting values for the Transform, but the values seem to be almost...inverted. It should look half a square, ending at frequency, f, of 20. But instead it looks flipped, and all values are almost 0 until just before f = 20.
any suggestions?
^similiar to what I'm looking to get
  2 commentaires
Walter Roberson
Walter Roberson le 4 Mar 2012
Do you possibly need to fftshift() to get what you are looking for?
B T
B T le 4 Mar 2012
Im probably not using it right right now, but I will look into it more tomorrow morning. Thank you though, I think this might lead to the solution.

Connectez-vous pour commenter.


B T
B T le 4 Mar 2012
bump, thanks

Catégories

En savoir plus sur Fourier Analysis and Filtering dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by