【问题标题】:How to plot the frequency response of butterworth filters using MATLAB如何使用 MATLAB 绘制巴特沃斯滤波器的频率响应
【发布时间】:2012-12-18 23:40:12
【问题描述】:

我构建了一个代码来使用 Butterworth IIR 设计 4 个滤波器。低、高、带通和带阻。 Input Diolog 窗口打开以接受用户输入,我将默认值设置为:

def = {'5','200','40','50','3','30'}; for Low and High pass
AND
def = {'5','500','60', '200','50','250','3','30'}; for bandpass and bandstop
Order of Filter
Fsampling (Hz)
Fpass (Fpass 1 and 2) (Hz)
Fstop (Fstop 1 and 2) (Hz)
Ripple factors (dB)
Stop attenuation (dB)

暂且用for循环(1-->4)计算B和A分量

   [n Fn] = buttord(Fpass,Fstop,Rp,Rs);
   [B,A] = butter(N,Fn,str);
   B_Comp{i} = B;
   A_Comp{i} = A;

现在..我需要为每个滤波器绘制它们的频率响应,所以使用

for i=1:4
   freqz(B_Comp(i),A_Comp(i));
   figure;
end

但是出现了这个错误:

 ??? Function 'fft' is not defined for values of class 'cell'.
Error in ==> fft at 36
   [varargout{1:nargout}] = builtin('fft', varargin{:});

Error in ==> freqz at 94
    h = dividenowarn(fft(b,s.*nfft),fft(a,s.*nfft)).';

Error in ==> dsp1 at 62
    freqz(B_Comp(i),A_Comp(i));

我该如何解决这个问题.. 任何帮助表示赞赏

【问题讨论】:

    标签: matlab filter frequency


    【解决方案1】:

    当你想fft 时不要使用单元格,请先尝试使用cell2mat。例如:

     freqz(cell2mat(B_Comp(i)),cell2mat(A_Comp(i)));
    

    【讨论】:

    • 我可以使用:freqz(B_Comp{i},A_Comp{i}).. 注意大括号而不是括号
    猜你喜欢
    • 2015-07-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-26
    相关资源
    最近更新 更多