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)|')
------------------------------------------------------------
Positive FFT is function with
function[YfreqD,freqRng]=positiveFFT(y,Fs)
N=length
;
k=0:N-1;
T=N/Fs;
freqRng=k/T;
YfreqD=fft
/N;
cutOff=ceil(N/2);
YfreqD=YfreqD(1:cutOff);
freqRng=freqRng(1:cutOff);