Filter characteristics of smoothdata function ?
1 回表示 (過去 30 日間)
古いコメントを表示
Suvvi Kuppur Narayana Swamy
2022 年 9 月 5 日
コメント済み: Star Strider
2022 年 9 月 7 日
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!