我加入了在这里使用的示例信号链路exampleSignal
我的信号是“ ydata”。为了高通我尝试的信号:
vidInfo.frameRate = 29.9293;
highPassedSig = highpass(ydata,4,vidInfo.frameRate) % vidInfo.frameRate
在我看来,存在一些严重的边缘伪像。如果我删除前50个样本和后50个样本,则这是信号的中心部分:
To get rid of the edge artifact, I tried to make the signal longer at the beginning and the end. I tried two approaches: 1) zero padding, 2) doubling the first and last 50 samples of the signal. The zero padding didn't work. I found some code on mathworks for the second approach:
R=0.1; % 10% of signal
Nr=50;
N=size(ydata,1);
NR=min(round(N*R),Nr); % At most 50 points
for i=1:size(ydata,2)
ydata1(:,i)=2*ydata(1,i)-flipud(ydata(2:NR+1,i)); % maintain continuity in level and slope
ydata2(:,i)=2*ydata(end,i)-flipud(ydata(end-NR:end-1,i));
end
sigToHighPass=[ydata1;ydata;ydata2];
% Do filtering
highPassedSig = highpass(sigToHighPass,4,vidInfo.frameRate);
highPassedSig = highPassedSig(NR+1:end-NR,:)
It looks like the edge artifact is removed. At this point, I tried to apply the low-pass filter to the highpass filtered data.
N=size(highPassedSig,1);
NR=min(round(N*R),Nr); % At most 50 points
for i=1:size(highPassedSig,2)
highPassedSig1(:,i)=2*highPassedSig(1,i)-flipud(highPassedSig(2:NR+1,i)); % maintain continuity in level and slope
highPassedSig2(:,i)=2*highPassedSig(end,i)-flipud(highPassedSig(end-NR:end-1,i));
end
sigToLowPass=[highPassedSig1;highPassedSig;highPassedSig2];
% Do filtering
lowPassedSig = lowpass(sigToLowPass,0.7,vidInfo.frameRate);
lowPassedSig=lowPassedSig(NR+1:end-NR,:)
This is the result Once again, it looks like there is some serious edge artifact.
I also tried other approaches. For instance:
d = designfilt('lowpassfir', 'FilterOrder', 5, 'CutoffFrequency', 0.7, 'SampleRate', vidInfo.frameRate);
lowPassedSig = filter(d, ydata);
This is the result (subplot3):
Does anyone have any idea how can I deal with this?
Thank you, Gianluca
我在您的方法中看到的根本问题是您误解了截止频率。如果要删除低于0.7 Hz且高于4 Hz的频率,则需要:
并非相反!按照您的建议使用highpass
和lowpass
函数可以轻松完成此操作。他们正在自动处理填充。如果您愿意,您可以设计具有上述截止频率的数字滤波器BUT :)
一个Matlab代码可以满足您的要求:
ydata = load("signaldata.mat","-mat");
ydata = ydata.ydata;
f = 29.9293;
lp = 0.7;
hp = 4;
[y_hp,d_hp] = highpass(ydata,lp,f);
[y_lphp,d_lp] = lowpass(y_hp,hp,f);
%% plot result
x = (1:length(ydata))/f;
figure;
subplot(3,1,1);
plot(x,ydata);
legend("Original");
subplot(3,1,2);
plot(x,y_hp);
legend("Highpass");
subplot(3,1,3);
plot(x,y_lphp);
xlabel('Time [s]');
legend("Lowpass");
%% plot filters
figure;
[h,w] = freqz(d_hp);
subplot(2,2,1);
title('Highpass');
loglog(w/pi*f/2,abs(h));
subplot(2,2,3);
semilogx(w/pi*f/2,angle(h)/pi*180);
[h,w] = freqz(d_lp);
subplot(2,2,2);
title('Lowpass');
loglog(w/pi*f/2,abs(h));
subplot(2,2,4);
semilogx(w/pi*f/2,angle(h)/pi*180);
这给出了以下图表:输入和输出数据滤波器的频率响应(幅度和相位)。
希望这种解释对您有所帮助!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句