📄 cp10_3.m
字号:
%%%%%%%%%%% Comprehensive Problem 10.3 %%%%%%%%%%
% 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 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Electric Power Generation System
clear all, close all
disp('Comprehensive Problem CP10.3')
dpower2 % load power system model with extra damping
disp('*****>'), pause
disp('Power system model state matrices, with Vterminal, ')
disp(' w(speed), and P(power) as output')
disp('Continuous-time model')
Gs
disp('*****>'), pause
disp('discretized model with a sampling period of 0.01 s')
Ts = 0.01
Gz = c2d(Gs,Ts)
disp('Note that most of the zero entries of the A & B matrices')
disp(' of the continuous time model have become nonzero in the')
disp(' discrete time models. The C & D matrcies are unchanged.')
disp('*****>'), pause
disp('System model with Vterminal as the only output')
Gv = Gz(1,1)
disp('*****>'), pause
% extract system matrices
[Ad,Bd,Cd,Dd] = ssdata(Gv);
% find eigenvalues
disp('Open-loop system poles')
lam = eig(Ad);
xy2p(lam);
disp('*****>'), pause
% assign full state feedback eigenvalues
lams = lam;
lams(7) = 0.98; % shift 0.9989 mode to 0.98
disp('assign full-state-feedback eigenvalues at ')
xy2p(lams);
disp('*****>'), pause
disp('full-state-feedback gain')
K = place(Ad,Bd,lams)
disp('*****>'), pause
% assign observer eigenvalues
lamo = lam;
lamo(7) = 0.96;
disp('assign observer eigenvalues at ')
xy2p(lamo);
disp('*****>'), pause
disp('observer gain')
L = place(Ad',Cd',lamo);
L = L'
disp('*****>');pause
A_f = Ad-Bd*K-L*Cd; % controller system matrix
f_poles = eig(A_f); % controller poles
disp('Controller poles')
xy2p(f_poles);
disp('Controller zeros')
f_zeros = tzero(A_f,-L,-K,0); % controller zeros
xy2p(f_zeros);
disp('*****>');pause
Gc = ss(A_f,-L,-K,0,Ts);
ww = logspace(-1,2,100);
figure, bode(Gc,ww), grid % frequency response plot
title('CP10.3: Frequency response of controller')
disp('Plotting controller frequency response')
disp('*****>');pause
%
GK = Gv*Gc;
figure, margin(GK)
disp('Plotting gain and phase margins of the compensated system')
disp('*****>');pause
%
Gcl = feedback(GK,1); % closed-loop system
disp('closed-loop system poles')
xy2p(pole(Gcl)); % closed-loop system poles
disp('*****>');pause
figure, [y,t] = step(Gcl,6);
plot(t,0.05*y,'o')
xlabel('Time (s)')
ylabel('Amplitude')
grid;title('CP10.3: Step response of closed loop system')
%
disp('end of Comprehensive Example 10.3')
%%%%%%%%%%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -