Now I understand what you want to do. This is most easily done with the Signal Processing Toolbox sgolayfilt function to create the Savitzky-Golay filtered spectrum.
The Code —
D = load('Isma_gp TENS_LOW.mat');
sig = D.TENS_LOW_42;
sig = sig - mean(sig);
L = length(sig);
Fs = 1/0.0117;
Fn = Fs/2;
FTsig = fft(sig)/L;
Fv = linspace(0, 1, fix(length(FTsig)/2)+1)*Fn;
Iv = 1:length(Fv);
FTsiga = double(abs(FTsig(Iv))*2);
sgf_sm = sgolayfilt(FTsiga, 5, 501);
figure(1)
plot(Fv, FTsiga)
hold on
plot(Fv, sgf_sm, '-r', 'LineWidth',2)
hold off
axis([0 1 ylim])
grid
xlabel('Frequency')
ylabel('Amplitude')
legend('Original Spectrum', 'Savitzky-Golay Filtered Spectrum')
Experiment with the sgolayfilt parameters to get the result you want.
Best Answer