如何用MATLAB绘制butterworth滤波器的频率响应
我构建了一个代码,用巴特沃斯IIR设计了4个过滤器。低、高、带通和带阻。 Input Diolog窗口打开以接收用户输入,我将默认值设置为:如何用MATLAB绘制butterworth滤波器的频率响应,matlab,filter,frequency,Matlab,Filter,Frequency,我构建了一个代码,用巴特沃斯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 (
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));
我该如何解决这个问题。。感谢您的帮助当您想
fft
时,请不要使用单元格,请在使用cell2mat
之前先尝试一下。例如:
freqz(cell2mat(B_Comp(i)),cell2mat(A_Comp(i)));
当您想要
fft
时,不要使用单元格,请尝试使用cell2mat
。例如:
freqz(cell2mat(B_Comp(i)),cell2mat(A_Comp(i)));
我能用:freqz(B_Comp{I},A_Comp{I})吗。。注意大括号而不是括号扫描,我只使用了:freqz(B_Comp{I},A_Comp{I})。。请注意大括号而不是括号