FFT issue

6 Ansichten (letzte 30 Tage)
B T
B T am 3 Mär. 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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 3 Mär. 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 Kommentar
B T
B T am 3 Mär. 2012
Thank you.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (2)

B T
B T am 3 Mär. 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 Kommentare
Walter Roberson
Walter Roberson am 4 Mär. 2012
Do you possibly need to fftshift() to get what you are looking for?
B T
B T am 4 Mär. 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.

Melden Sie sich an, um zu kommentieren.


B T
B T am 4 Mär. 2012
bump, thanks

Kategorien

Mehr zu Fourier Analysis and Filtering finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by