Filter characteristics of smoothdata function ?
1 次查看(过去 30 天)
显示 更早的评论
Hi all,
I am using a matlab inbuilt function called smoothdata as a low pass filter to remove all the high freqeuncy components from my recorded PPG (photoplethysmography) signal.The sampling frequency was = 100Hz. I want to find out filter characteristics such as frequency response, roll off of my specified smoothdata filter. So is using freqz or fvtool the right way to approach this problem? or is there any suggestions or advice on this please?
fs = 100;
smooth_red= smoothdata(red,'rloess',100); % signal at red wavelength
freqz(smooth_red);
fvtool(smooth_red);
0 个评论
采纳的回答
Star Strider
2022-9-5
‘So is using freqz or fvtool the right way to approach this problem?’
No. The freqz function wants filter coefficients.
The optimal approach is to use either the fft (or pspectrum) functions to get a Fourier transform of the filtered and unfiltered signals. Then the transfer function (that is what you want to calculate) is —
s = original_signal;
s_filt = filtered_signal;
Fs = 1/(x(2)-x(1));
Fn = Fs/2;
L = numel(signal);
NFFT = 2^nextpow2(L);
FTssf = fft([s(:) s_filt(:)], NFFT)/L;
Fv = linspace(0, 1, NFFT/2+1)*Fn;
Iv = 1:numel(Fv);
transfer_function = FTssf(:,2) ./ FTssf(:,1);
figure
plot(Fv, mag2db(abs(transfer_function(Iv))))
grid
xlabel('Frequency')
ylabel('Power (dB)')
I haven’t tested this, however it should work. The independent variable vector (assumed to be ‘x’ here) must have a constant sampling interval for this to work correctly. The filtered and unfiltered signals must also be the same lengths.
.
2 个评论
Star Strider
2022-9-7
It appears to have a narrow biphasic characteristic with frequencies of about 2.2 tp 2.6 and what appears to be a sort of bandstop characteristic at about 4 to 5. The code appears to be correct, so I only used the transfer function plot here.
There is not much to be said about it otherwise, other than it is an interesting investigation into the frequency characteristics of that particular smoothing function when applied to your data. It does not appear to be affecting the isgnal much.
F = openfig(websave('Transfer Function','https://www.mathworks.com/matlabcentral/answers/uploaded_files/1118585/Transfer%20function.fig'));
Lines = findobj(F, 'Type','line');
[Ymax,idx1] = max(Lines.YData)
FreqMax = Lines.XData(idx1)
[Ymin,idx2] = min(Lines.YData)
FreqMin = Lines.XData(idx2)
figure
plot(Lines.XData, mag2db(Lines.YData))
grid
xlabel('Frequency')
ylabel('Power (dB)')
title('Transfer Function')
xlim([0 8])
The frequency resolution might have been slightly better had it been zero-padded (using the ‘NFFT’ variable to extned its fft length to a power-of-2 greater than its actual length). I doubt much is lost by not doing that.
.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multirate Signal Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!