2012-12-18 120 views
0

我使用butterworth IIR構建了一個設計4個濾波器的代碼。低,高,帶通和帶阻。 輸入Diolog窗口打開採取在用戶輸入,我設置的默認值,以:如何使用MATLAB繪製巴特沃思濾波器的頻率響應

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) 

的時間being.and使用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; 

Now..I需要繪製其頻率響應爲每個過濾器,所以使用

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)); 

我如何解決這個問題..任何幫助表示讚賞

回答

3

當你想fft不使用電池,嘗試使用cell2mat之前。例如:

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

我能不能用:freqz(B_Comp {I},{A_Comp我})..請注意括號,而不是括號 – user1111726

+0

這是另一種選擇,但你已經知道... – bla

相關問題