graphing a fourier transform function
15 ビュー (過去 30 日間)
古いコメントを表示
I have a function: f=gaussmf(x,[3,10]), and wanting to plot the magnitude if its fourier transform. I am defining the frequency, s, to be s= x*(1/N). x is my independent variable vector for the original function and goes from 0:250. N is my number of x points being input into the original function, which in this case is 251. I am wanting to plot the magnitude of my FT as a function of s.
When I do this I am using the fftshift(FT(f)) but I want to be able to see my plot in its original location along s, not shifted along the s-axis, where the peak is not in the 'correct' location along the s-axis.
What I am trying to say is when I plot fft(FT(f)), I am only seeing the tails of the FT plot. I simply want to 'shift' the plot so I can see the entire curve along its original location, however I don't want to shift the function along the s-axis.
0 件のコメント
採用された回答
Matt J
2013 年 9 月 22 日
編集済み: Matt J
2013 年 9 月 22 日
I don't quite understand what you want, but if you are using f=gaussmf(0:250,[3,10]) to construct f,then the left tail of the Gaussian looks like it would be highly under-sampled. That may be why the shape of the FFT is not as you expect.
If f is centered at 10, you probably want to sample symmetrically around 10
f=gaussmf(10+(-126:126), [3,10])
although why you don't simply just center the gaussian at zero is unclear to me.
f=gaussmf(-126:126, [3,0])
Since you only want the magnitude spectrum, shifting the peak to x=10 has no effect and just complicates things.
2 件のコメント
Matt J
2013 年 9 月 22 日
編集済み: Matt J
2013 年 9 月 22 日
Never mind what I said about undersampling, although I do think sampling x more finely gives a noticeably smoother plot of gaussmf(x,[3,10]). But anyway, when I run the code below, I get a nice Gaussian-looking magnitude spectrum centered at s=0 ... all as expected. If this is not what you're after, you can use this is as basis for explaining what you're doing differently.
%Axes
x=linspace(0,250,501); %x-axis
N=length(x);
dx=x(2)-x(1);
ds=1/N/dx;
s=( (0:N-1) -ceil((N-1)/2) )*ds; %freq axis
%Signals
G=@(x,sig,c)exp(-(x-c).^2/2/sig^2);
f=G(x,3,10);
F=fftshift(abs(fft(f)*dx));
%Plots
figure(1);
plot(x,f);
figure(2);
plot(s,F)
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!