📄 cp4_2.m
字号:
%%%%%%%%%%% Comprehensive Problem 4.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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Inverted Pendulum% System has 4 states, 1 input, and 2 outputs% 4 states : pendulum's angular position and velocity, and% cart's position and velocity% 1 input : motor voltage (u)% 2 outputs: pendulum's angular position (theta)% cart's position (x) disp('CP4.2: Inverted Pendulum')%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Part A : Load model%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%clear; close all% Load continuous and discrete-time systemsif ~exist('stick.mat'), dstickelseif exist('stick.mat') == 2, load stickendTs = 0.01; % in dstick alreadydisp('*******>'); pause; disp(' ');%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Part B : Compute Poles%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%disp(['The matrices of the state-space model Gz(z) are :'])[A,B,C,D] =ssdata(Gz)disp('*******>');pause; disp(' ');disp('System eigenvalues:')disp(' one at z = 1 - position of cart without a reference point')disp(' one outside of the unit circle - unstable motion of pendulum')disp(' two inside the unit circle - stable motion of pendulum and ')disp(' cart.')eig(A)disp('*******>');pause; disp(' ');%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Part C : Simulation%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%disp('initial conditions')x0 = [0.1 -0.6002 0 0]'dtime = [0:Ts:1]';y = lsim(Gz,0*dtime,dtime,x0);figurestem(dtime,y), gridtitle('Initial Condition Response to 0.1 rad pendulum angle');ylabel('Pendulum angle (rad) and cart position (m)')xlabel('Time (s)')legend('pendulum angle','cart position')disp('*******>');pause%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Part D : Modal form%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%disp('Modal form')Gzm = canon(Gz,'modal')disp('The eigenvalues are on the diagonal of the modal form A matrix')disp('End of Comprehensive Problem CP4.2')%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -