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!