Prev: image processing
Next: Fuzzy logic toolbox
From: Agus Nugroho on 3 Jun 2010 11:19 Dear All, I would like to ask you in such problem that i am facing now, since i am still beginner in the Matlab programming. Currently, I have signal with length of 1000 sample and I would like to devide it to be 10 segments so each of them will have 100 sample. For each segment I would like to implement FFT and windowed function. And finally, I want to calculate the average FFT for these 10 segments. I have FFT program but it i is used for calculating for FFT of 1000 samples. I have tried to use "for" function but it seems useless for me. Would you help me by correcting my sample signal below to fulfill my objective? Thank you in advance ---------------------------------------------------------------------------------------- Fs=100; Ts=1/Fs; t=0:Ts:1000-Ts; n=length(t); y=2*sin(2*pi*0.5*t)+5*sin(2*pi*0.2*t)+10*sin(2*pi*0.1*t)+20*sin(2*pi*0.05*t); figure(1) plot(t,y) windowHann=window(@hann,n).'; hannWindowFigure=figure; plot(windowHann); windowedSignal=windowHann.*y; windowedSignalPlot=figure; plot(t,windowedSignal) [Yk,k]=positiveFFT(windowedSignal,Fs); Yk=Yk*2; fftWindowedSignalLinear=figure; stem(k,2*abs(Yk)); xlabel('Spatial frequency (m-1)') ylabel('|Y(k)|') ------------------------------------------------------------
From: Agus Nugroho on 3 Jun 2010 12:50 Positive FFT is function with : 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);
From: TideMan on 3 Jun 2010 16:17 On Jun 4, 4:50 am, "Agus Nugroho" <agus_nugroh...(a)yahoo.com> wrote: > Positive FFT is function with : > 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); This all looks pretty good to me. The only thing I'd change is the range: YfreqD(2:cutOff) and freqRng(2:cutOff). This excludes the DC (zero frequency) component. As for ensemble averaging, you just need to split your signal using reshape: y1=reshape(y,100,10); then loop through each column applying the window and positiveFFTy to each. You need to have a go at this and come back to us if you have a problem.
From: Agus Nugroho on 4 Jun 2010 06:24 Dear Dr TideMan, Actually I have arround 30 segments so its little bit difficult to examine one by one. However, I tried to make the function "for", but it seems not working well. May you see what is wrong in my function sir? I am sorry since I just new in this field so perhaps the logarithms is mistakes. ------------------------------------------------------------------------------ fo=5; Fs=100; Ts=1/Fs; t=0:Ts:0.9-Ts; N=length(t); y=2*sin(2*pi*fo*t); Nseg= 10; %Number of segments n=floor(N/Nseg); %Nu. of samples per segment Y_average=zeros(1,n); for I=1:Nseg %number of segment w=hann(n); y1=y(1:n,I); %signal from segment 1 until segment 10 windowedSignal=(w(1:n,I).*y1; %windowoded signal for each segment Y=fft(windowedSignal,n); %fft for each signal segment end %averages FFT Y_average=Y_average+Y.*conj(Y); stem(abs(Y_average)); ---------------------------------------------------------- Thank you very much
From: Agus Nugroho on 7 Jun 2010 05:15 Dear Dr. Mulgor, I have modify the algorithm as suggested from you in the previous email and its work. You are so mch helpful Thank you for your kindness. Best regards, Agus
|
Pages: 1 Prev: image processing Next: Fuzzy logic toolbox |