📄 reinf6_6.m
字号:
%%%%%%%%%%% Reinforcement Problem 6.6 %%%%%%%%%%%
% 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 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ---- Chebyshev II bandstop filter ----
%
clear
disp('Reinforcement Problem 6.6')
Ts = 0.01;
%---- define system from Prob. 6.3
G = tf(0.4207*[1 0 1.7994 0 1],[1 0 0.3773 0 0.2210],Ts)
%-- first, draw Bode plot of filter to have as a guide ----
figure
bode(G)
%---- Part (a) --------------------
k1 = [0:1:100]'; % generate time window
k1Ts = k1*Ts;
w1 = 4*pi % input frequency, rps
e1 = 2.0*sin(w1*k1Ts + 20*pi/180); % input signal
y1 = lsim(G,e1); % simulate time response
[magw1,phw1] = bode(G,w1) % mag and phase at w1
y1ss = magw1*2*sin(w1*k1Ts + (20+phw1)*pi/180); % eqn 6.3, but using sin
%-- magnitude and phase of steady-state y1 at w1
mag_y1_w1 = 2*magw1 % s-s magnitude
ph_y1_w1 = 20+phw1 % s-s phase in degrees
figure
subplot(211)
plot(k1Ts,e1,'*');grid
xlabel('k1Ts (s)')
legend('e1')
title('Reinforcement Problem 6.6(a)')
subplot(212)
plot(k1Ts,y1,'*');grid
hold on
plot(k1Ts,y1ss,'o')
hold off
xlabel('k1Ts (s)')
legend('y1','y1ss')
axis([0 k1Ts(end) -2 2]);
%---- Part (b) --------------------
k2 = [0:1:30]'; % generate appropriate time window
k2Ts = k2*Ts;
w2 = 60*pi % input frequency, rps
e2 = 2*cos(w2*k2Ts - 145*pi/180); % input signal
y2 = lsim(G,e2); % simulate time response
[magw2,phw2] = bode(G,w2) % mag and phase at w2 = 60 rps
y2ss = magw2*2*cos(w2*k2Ts + (-145+phw2)*pi/180); % eqn 6.3
%-- magnitude and phase of steady-state y2 at w2
mag_y2_w2 = 2*magw2 % s-s magnitude
ph_y2_w2 = -145+phw2 % s-s phase in degrees
figure
subplot(211)
plot(k2Ts,e2,'*');grid
hold on
plot(k2Ts,e2,':')
hold off
xlabel('k2Ts (s)')
legend('e2')
axis([0 0.30 -2.5 2.5])
title('Reinforcement Problem 6.6(b)')
subplot(212)
plot(k2Ts,y2,'*');grid
hold on
plot(k2Ts,y2,':')
plot(k2Ts,y2ss,'o')
hold off
axis([0 0.30 -0.5 0.5])
xlabel('k2Ts (s)')
legend('y2','y2ss')
%%%%%%%%%%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -