Prev: problem assigning variables with eval - nameclash with existing functions
Next: vim as editor for .m files
From: Greg Heath on 2 Jul 2010 07:26 On Jul 1, 10:01 am, "Agus Nugroho" <agus_nugroh...(a)yahoo.com> wrote: > Dear comrade in arms, > > I would like to ask you concerning the problem that I am facing now and I hope you do not mind to help me. > > I have tested a sinusoidal signal to find it's auto spectrum with algorithms (X- axis represents frequency and Y-axis represents Amplitude). The X-axis (frequency) of the curve is correct, however, I am not really sure about the Y-Axis (amplitude). Could you help me by seeing my algorithm below whether that is correct to find its amplitude? : > > ------------------------------------------------------------------------- > Fs=20; > Ts=1/Fs; > t=0:Ts:12.75; > n=length(t); > y=sin(2*pi*0.3515*t); %generate sinusoidal wave with freq 0.3515 > figure(1) > plot(t,y) > > [YfreqD,freqRng]=positiveFFT(y,Fs); > > figure(2) > YfreqDb=2*abs(YfreqD); % amplitude scale > > Auto_sp=2*(conj(YfreqDb).*YfreqDb); %auto spectrum signal > > Auto_scale=sqrt(2*Auto_sp)*(2/256); %Auto spectrum scale, 256 is nfft > > plot(freqRng, Auto_scale) > > ----------------------------------------------------------------------------------- > > the algorithm for function : > > function[YfreqD,freqRng]=positiveFFT(windowedSignal,Fs) > N=length(windowedSignal); > k=0:N-1; > T=N/Fs; > freqRng=k/T; > YfreqD=fft(windowedSignal)/N; > cutOff=ceil(N/2); > YfreqD=YfreqD(1:cutOff); > freqRng=freqRng(1:cutOff); > ------------------------------------------------------------------- > > Thank you very much for your help. > > Kindest regards, > > Agus Im general, cutoff = ceil((N-1)/2) (Just in case you run into examples with N odd). Hope this helps. Greg
From: Agus Nugroho on 2 Jul 2010 07:42 Dear Dr. Grade, Thank you for your correction. Regards, Agus
From: Greg Heath on 2 Jul 2010 08:51 On Jul 2, 7:42 am, "Agus Nugroho" <agus_nugroh...(a)yahoo.com> wrote: > Dear Dr. Grade, > > Thank you for your correction. > > Regards, > > Agus I've been called a lot of things; but never that! Greg
First
|
Prev
|
Pages: 1 2 Prev: problem assigning variables with eval - nameclash with existing functions Next: vim as editor for .m files |