0

我构建了一个代码来使用 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));

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

4

1 回答 1

3

想用的时候不要用cell fft,用之前先试试cell2mat。例如:

 freqz(cell2mat(B_Comp(i)),cell2mat(A_Comp(i)));
于 2012-12-19T00:13:57.923 回答