フィルターのクリア

how to do sampling and filtering for the data?

17 ビュー (過去 30 日間)
Keshasni Earichappan
Keshasni Earichappan 2021 年 8 月 15 日
コメント済み: Star Strider 2021 年 8 月 15 日
hi good day..Anyone know how to do the steps as i mentioned below.I have tried but i coudn't find the right results
1-MC-sensor data need to sampled at 1000Hz
2-Moving Average method was used to down-sample the mc-sensor data to 100 Hz
3-MC-sensor data need to filtered at 5 Hz using a 4th order butter-worth filter

採用された回答

Star Strider
Star Strider 2021 年 8 月 15 日
There is no reason to downsample it. Just resample it to a 1 kHz sampling frequency (since the sampling intervals are not regular), then filter it. Calculating a moving average will not downsample it anyway. It will just filter it, and that is not necessary since the actual desired filtering will be with the Butterworth filter.
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/712412/MC.txt', 'VariableNamingRule','preserve');
Fs = 1E+3;
Fn = Fs/2;
[MCvr,tr] = resample(T1.('MC[v]'),T1.Time, Fs);
[z,p,k] = butter(4, 5/Fn,'low');
[sos,g] = zp2sos(z,p,k);
MCvrfilt = filtfilt(sos,g,MCvr);
figure
subplot(2,1,1)
plot(T1.Time, T1.('MC[v]'))
yl = ylim;
grid
subplot(2,1,2)
plot(tr, MCvrfilt)
ylim(yl)
grid
.
  2 件のコメント
Keshasni Earichappan
Keshasni Earichappan 2021 年 8 月 15 日
編集済み: Keshasni Earichappan 2021 年 8 月 15 日
Thank you so much @Star Strider..It's worked :)much appreciated...Besides, can i know how to down-sample the data to 100Hz using moving average method because there are difference between sampling rates of this data with another data.I need to downsample it in order to match the sampling rate of my another data.
Star Strider
Star Strider 2021 年 8 月 15 日
My pleasure.
Use the resample function to resample the data to a different sampling frequency. The moving average method is not appropriate for that. Use the filter either with the original or resampled signal. It should work for both, however ‘Fs’ and ‘Fn’ will be different. One option for that is simply to downsample it originally:
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/712412/MC.txt', 'VariableNamingRule','preserve');
Fs = 1E+2; % Resample At 100 Hz Instead Of 1000 Hz
Fn = Fs/2;
[MCvr,tr] = resample(T1.('MC[v]'),T1.Time, Fs);
[z,p,k] = butter(4, 5/Fn,'low');
[sos,g] = zp2sos(z,p,k);
MCvrfilt = filtfilt(sos,g,MCvr);
figure
subplot(2,1,1)
plot(T1.Time, T1.('MC[v]'))
yl = ylim;
grid
subplot(2,1,2)
plot(tr, MCvrfilt)
ylim(yl)
grid
.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDigital Filter Analysis についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by