MATLAB real-time filtering implement
显示 更早的评论
How can implement a real-time filter in matlab. My goal is to design a filter with 100Hz cutoff frequency and 1dB attenuation in passband. My incoming signal has the sample rate of 10kHz. The signal is coming frame by frame. One frame contain 60 sample.
I tried following code but the result is bad. I kind know the problem is I filter the data every frame, but I don't know how to address that since it will be a real-time system and I have to process data frame by frame.
clear all
% Test Seq generate %
T = 9*(1/50);
fs = 10000;
t = 0:1/fs:T-1/fs;
testSeqComb = 3 * (sin(2*pi*50*t) + 0.5*sin(2*pi*500*t) + 0.25*sin(2*pi*1000*t));
blockNum = length(testSeqComb)/60;
for i=1:blockNum
testSeq(i,:) = testSeqComb(1+(i-1)*60:i*60);
end
% Raw Data Visualize %
plot(t, testSeqComb)
hold on
% Filter %
filter1 = designfilt('lowpassiir', 'FilterOrder', 6, 'HalfPowerFrequency', 100, 'SampleRate', 10000);
for i=1:blockNum
testSeqFiltered(i,:) = filtfilt(filter1, testSeq(i,:));
end
testSeqFilteredComb = [];
for i=1:blockNum
testSeqFilteredComb = [testSeqFilteredComb testSeqFiltered(i,:)];
end
% Filtered Data Visualize %
plot(t, testSeqFilteredComb, "LineWidth", 2)
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Single-Rate Filters 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

