我构建了一个使用butterworth IIR设计4个滤镜的代码。低,高,带通和带阻。 输入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));
我如何解决这个问题..感谢任何帮助
答案 0 :(得分:3)
如果您想fft
,请不要使用单元格,请先尝试使用cell2mat
。例如:
freqz(cell2mat(B_Comp(i)),cell2mat(A_Comp(i)));