ep6_2.m

来自「离散控制系统设计的MATLAB 代码」· M 代码 · 共 41 行

M
41
字号
%%%%%%%%%%%% Exploratory problem 6.2 %%%%%%%%%%%%%   Discrete-Time Control Problems using        %%       MATLAB and the Control System Toolbox   %%   by J.H. Chow, D.K. Frederick, & N.W. Chbat  %%         Brooks/Cole Publishing Company        %%                September 2002                 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   ---- Finite-impulse response filter ----%cleardisp('Exploratory Problem 6.2 - Finite-impulse response filter ')Ts = 0.01;                        % sampling periodw0 = 50*pi;a = 0.5, b = 0.95, K = 0.13num = K*conv([1 -a*exp(j*w0*Ts)],[1 -a*exp(-j*w0*Ts)]);den = conv([1 -b*exp(j*w0*Ts)],[1 -b*exp(-j*w0*Ts)]);G = tf(num,den,Ts)			      % bandpass filter as TF object n = input('Enter the order of the FIR filter > ')num_FIR = deconv([num zeros(1,n)],den);   % long divisionden_FIR = [1 zeros(1,n)];                 % all poles at originG_FIR = tf(num_FIR,den_FIR,Ts)ww = [0:0.01:1]*pi/Ts;[mag,ph] = bodedb(G,ww);[mag_FIR,ph_FIR] = bodedb(G_FIR,ww); figuresubplot(2,1,1)semilogx(ww,mag,ww,mag_FIR,'--'), gridlegend('IIR','FIR')ylabel('Magnitude (dB)')subplot(2,1,2)semilogx(ww,ph,ww,ph_FIR,'--'), gridlegend('IIR','FIR')ylabel('Phase (deg)')xlabel('Frequency (rad/s)')disp('End of Exploratory Problem 6.2')%%%%%%%%%%

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?