Octave/Matlab 过滤器与 fftfilter

问题描述

所以我正在使用八度音程对特定信号应用降噪算法,这就是代码

clc;
clear;
pkg load signal 


x = csvread("Ascan.csv");
tres = 50 /length(x);
t = [0:tres:50-tres];
MHz = 10;
fres = 1/tres;
f1 = 0.5*MHz;
f2 = 6*MHz;

numberofOverlaps = 50;
freqChange = (f2-f1)/numberofOverlaps;
count =0;
fs = 50 * MHz;
Rpass = 1;
Rstop = 26;
fp1 = f1:freqChange:f2-freqChange;
fp2 = f1+2*freqChange:freqChange:f2+freqChange;
for i = 1:numberofOverlaps
  fs1 = fp1(i) - 1*MHz;
  fs2 = fp2(i) + 1*MHz;
  if fs1<0
    fs1 =0;
  endif
  fpass{i} = [fp1(i) fp2(i)];
  fstop{i} = [fs1 fs2];
  Wpass = 2 /fs * fpass{i};
  Wstop = 2/fs * fstop{i};
  [n,Wp,Ws] = buttord(Wpass,Wstop,Rpass,Rstop);
  [b,a] = butter(n,Wp);
  filtered{i} = filter(b,a,x);
  fftfiltered{i} =fftfilt(b,x);
end


for L = 1:length(x)
  for k = 1:numberofOverlaps
    m1(k)= filtered{k}(L);
    m2(k)= fftfiltered{k}(L);
  endfor  
  minimalistic(L) = min(m1(k));
  minimal(L) = min(m2(k));
endfor

figure(1);
subplot(1,3,1);
plot(t,x);
title("Unfiltered");
xlabel('Time in us');
ylabel('Amplitude');
subplot(1,2);
plot(t,minimalistic);
title("filtered using filter function"); 
xlabel('Time in us');
ylabel('Amplitude');
subplot(1,3);
plot(t,minimal);
title("filtered using fftFilt function");
xlabel('Time in us');
ylabel('Amplitude'); 

在以下代码中,我将其作为输出

enter image description here

列 1 中的信号是输入信号,列 3 中的信号是所需的输出,但这使用函数 fftfilt(b,x),为什么它与 filter(b,x) 的工作方式不同,其输出显示第 2 列 中。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)