From: Agus Nugroho on 12 May 2010 07:02 Hi everyone, I have a data in spatial domain,, and I want to obtain the FFT spectrum which x-axis represented lambda. and my matlab algorithm is: Fs=100; Ts=1/Fs; x=0:Ts:1000-Ts; n=length(x); lambda_1=2; lambda_2=5; lambda_3=10; lambda_4=20; y=2*sin(2*pi*x/lambda_1)+5*sin(2*pi*x/lambda_2)+10*sin(2*pi*x/lambda_3)+20*sin(2*x/lambda_4); plot(t,y) [YfreqD,freqRng]=positiveFFT(y,Fs); figure(2) stem(freqRng,2*abs(YfreqD)); xlabel('Frequency (v/lambda)') ylabel('|Y(f)|') And for the normalize function I use : function[YfreqD,freqRng]=positiveFFT(y,Fs) N=length(y); k=0:N-1; T=N/Fs; freqRng=k/T; YfreqD=fft(y)/N; cutOff=ceil(N/2); YfreqD=YfreqD(1:cutOff); freqRng=freqRng(1:cutOff); However, my teacher said thats the plot result is wrong since the x-axis is represented frequency instead of lambda. Is it different in calculating FFT for spatial data and for time data?? Is there somebody can help to correct my algorithm? thanx alot
From: TideMan on 12 May 2010 16:27 On May 12, 11:02 pm, "Agus Nugroho" <agus_nugroh...(a)yahoo.com> wrote: > Hi everyone, > > I have a data in spatial domain,, and I want to obtain the FFT spectrum which x-axis represented lambda. > > and my matlab algorithm is: > > Fs=100; > Ts=1/Fs; > x=0:Ts:1000-Ts; > n=length(x); > lambda_1=2; > lambda_2=5; > lambda_3=10; > lambda_4=20; > y=2*sin(2*pi*x/lambda_1)+5*sin(2*pi*x/lambda_2)+10*sin(2*pi*x/lambda_3)+20*sin(2*x/lambda_4); > plot(t,y) > [YfreqD,freqRng]=positiveFFT(y,Fs); > figure(2) > stem(freqRng,2*abs(YfreqD)); > xlabel('Frequency (v/lambda)') > ylabel('|Y(f)|') > > And for the normalize function I use : > > function[YfreqD,freqRng]=positiveFFT(y,Fs) > N=length(y); > k=0:N-1; > T=N/Fs; > freqRng=k/T; > YfreqD=fft(y)/N; > cutOff=ceil(N/2); > YfreqD=YfreqD(1:cutOff); > freqRng=freqRng(1:cutOff); > > However, my teacher said thats the plot result is wrong since the x-axis is represented frequency instead of lambda. Is it different in calculating FFT for spatial data and for time data?? Is there somebody can help to correct my algorithm? > > thanx alot There is no difference in the way you calculate a frequency spectrum and a wave number spectrum. However, wave number is usually denoted by k, whereas you are using lambda, which I presume is wave length which is the inverse of k, so I suspect your teacher means that you must invert your freqRng: lambda=1./freqRng; then to preserve the spectrum plotting convention, you should put: set(gca,'XDir','reverse') and xlabel('Wave Length (v/lambda)')
From: TideMan on 12 May 2010 16:33 On May 13, 8:27 am, TideMan <mul...(a)gmail.com> wrote: > On May 12, 11:02 pm, "Agus Nugroho" <agus_nugroh...(a)yahoo.com> wrote: > > > > > Hi everyone, > > > I have a data in spatial domain,, and I want to obtain the FFT spectrum which x-axis represented lambda. > > > and my matlab algorithm is: > > > Fs=100; > > Ts=1/Fs; > > x=0:Ts:1000-Ts; > > n=length(x); > > lambda_1=2; > > lambda_2=5; > > lambda_3=10; > > lambda_4=20; > > y=2*sin(2*pi*x/lambda_1)+5*sin(2*pi*x/lambda_2)+10*sin(2*pi*x/lambda_3)+20*sin(2*x/lambda_4); > > plot(t,y) > > [YfreqD,freqRng]=positiveFFT(y,Fs); > > figure(2) > > stem(freqRng,2*abs(YfreqD)); > > xlabel('Frequency (v/lambda)') > > ylabel('|Y(f)|') > > > And for the normalize function I use : > > > function[YfreqD,freqRng]=positiveFFT(y,Fs) > > N=length(y); > > k=0:N-1; > > T=N/Fs; > > freqRng=k/T; > > YfreqD=fft(y)/N; > > cutOff=ceil(N/2); > > YfreqD=YfreqD(1:cutOff); > > freqRng=freqRng(1:cutOff); > > > However, my teacher said thats the plot result is wrong since the x-axis is represented frequency instead of lambda. Is it different in calculating FFT for spatial data and for time data?? Is there somebody can help to correct my algorithm? > > > thanx alot > > There is no difference in the way you calculate a frequency spectrum > and a wave number spectrum. > However, wave number is usually denoted by k, whereas you are using > lambda, which I presume is wave length which is the inverse of k, so I > suspect your teacher means that you must invert your freqRng: > lambda=1./freqRng; > then to preserve the spectrum plotting convention, you should put: > set(gca,'XDir','reverse') > and > xlabel('Wave Length (v/lambda)') Just to clarify, there is no difference between a frequency spectrum and a wave number spectrum providing you are transforming from time to frequency (y(t) => Y(f)) or space to wave number (y(x) => Y(k)), but if you are transforming from time to wave number (y(t) => Y(k)) or space to frequency (y(x) => Y(f)), then you need to apply a phase speed that may be a function of frequency (a dispersion relation).
From: Agus Nugroho on 13 May 2010 05:36 Thnk you very much sir.. I have tried your suggestion and its work.. Thank you again.. :)
From: Agus Nugroho on 13 May 2010 05:39 "Agus Nugroho" <agus_nugroho01(a)yahoo.com> wrote in message <hse1rd$qgc$1(a)fred.mathworks.com>... > Hi everyone, > > I have a data in spatial domain,, and I want to obtain the FFT spectrum which x-axis represented lambda. > > and my matlab algorithm is: > > Fs=100; > Ts=1/Fs; > x=0:Ts:1000-Ts; > n=length(x); > lambda_1=2; > lambda_2=5; > lambda_3=10; > lambda_4=20; > y=2*sin(2*pi*x/lambda_1)+5*sin(2*pi*x/lambda_2)+10*sin(2*pi*x/lambda_3)+20*sin(2*x/lambda_4); > plot(t,y) > [YfreqD,freqRng]=positiveFFT(y,Fs); > figure(2) > stem(freqRng,2*abs(YfreqD)); > xlabel('Frequency (v/lambda)') > ylabel('|Y(f)|') > > And for the normalize function I use : > > function[YfreqD,freqRng]=positiveFFT(y,Fs) > N=length(y); > k=0:N-1; > T=N/Fs; > freqRng=k/T; > YfreqD=fft(y)/N; > cutOff=ceil(N/2); > YfreqD=YfreqD(1:cutOff); > freqRng=freqRng(1:cutOff); > > > However, my teacher said thats the plot result is wrong since the x-axis is represented frequency instead of lambda. Is it different in calculating FFT for spatial data and for time data?? Is there somebody can help to correct my algorithm? > > thanx alot Thank you so much sir... I have tried your suggestion and its work, Thank you again :)
|
Pages: 1 Prev: Deconvolving an audio signal Next: www.voguesneakers.com Cheap Jordan Shoes,Cheap Nike Shoes |