Hi,
I have the following working code perfoming FFT analysis. I am still learning mathlab and signal processing however, I have been reading that in order to get a better FFT output one must apply zero padding and windowing.
I have come up with the following code with the help of online tutorials and this forum. The code is giving me what I want which is frequency components in the signal however i don't think it is achieving this doing zero padding and windowing.
My question when is it necessary to perform zero padding and windowing on the signal? and how can incorporate it in my code?
[D,S,R] = xlsread('test data.csv'); t = D(:,1); v = D(:,2);figureplot(t, v); % plot time domain signal
gridxlabel('Time')ylabel('Voltage')Signal = D(:,2); Ts = 0.00005; % Sampling Interval (seconds)
Fs = 1/Ts; % Sampling Frequency (Hz)
Fn = Fs/2; % Nyquist Frequency (Hz) half of the sampling rate of a discrete signal processing system
N = length(Signal);meanSignal = mean(Signal); % ‘Signal’ Mean
FTSignal = fft(Signal-meanSignal)/N; % Normalised Fourier Transform Of Baseline-Corrected ‘Signal’
Fv = linspace(0, 1, fix(numel(FTSignal)/2)+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
[pks,locs] = findpeaks(abs(FTSignal(Iv))*2, 'MinPeakHeight',0.044);figureplot(Fv, abs(FTSignal(Iv))*2)gridxlabel('Frequency(Hz)')ylabel('Amplitude')plotIdx = 1:Iv(max(locs));figureplot(Fv(plotIdx), abs(FTSignal(Iv(plotIdx)))*2)hold onplot(Fv(plotIdx(locs)), pks, '^r', 'MarkerFaceColor','r')title('FFT for Power Analysis')xlabel('Frequency (Hz)')ylabel('Amplitude')xlswrite('myfile.xls',Fv')xlswrite('myfile2.xls',abs(FTSignal(Iv))*2')hold off
Best Answer