博大广阔 发表于 2012-6-6 20:43

MATLAB 中控制系统命令介绍

%%%%%%%%%%%%%%%% MATLAB 中系统各种建模命令%%%%%%%%%%%%55

clc
clear all
close all
%MAlTab control
%matlab has a command to obtain the partial-fraction expansion of B(s)/A(s)
%and obtain the zeros and poles of B(s)/A(s)
den=;num=;
=residue(den,num);
=residue(r,p,k);
%note this command can convers the partial-fraction expansion back to the polyynomial radio
%B(s)/A(s).
printsys(den,num,'s');
%this command prints num/den in the terms of the radio of polynomial in s
num=;den=;
=tf2zp(num,den);
%this command use to finding zeros and poles of B(s)/A(s); where the K
%inplay the gain :bo note this
%of course have ,if the zeros poles and gain K are given ,then the
%following program will yield the original num/den
=zp2tf(z,p,k);
% be note when the resule of K=;means that F=s^2+2*s+3+...;
%note that i only the roots o a polynomial such as
clc
clear all
syms
d=;
r=roots(d);
d=poly(r);
%the command poly(r) produces the original polynomial


%2-2: 动力系统的数学模型
%MATLAB has usefull command to transform a mathematical modal of a
%linear-time-invariant system to another model .the folowing only suit to
%the linear system
% tf2ss: ss2tf conversionbetween state-space and transfer-function
% ss2zp :zp2ss   conversion between state-space and zero-pole
% tf2zp :zp2tf
%c2d continuous-time to dicrete -time conversion

%it is impotant to note that state-space representation of any systems is
%not unique.
A=;B=;
C=;D=;
=ss2tf(A,B,C,D,1);
%transformation from stste space to transfer function,the iu must be
%speccified for system with more than one iuput
%consider a system eith multiple inouts and multiple outputs.when the
%system has more than one output ,the command produces transfer function
%for all outputs to each input;

%conversion from continuous time to discrete time
A=;B=;
%farmat long
=c2d(A,B,0.05);
%where 0.05 is the sampling period; assuming a zero-order hold on the
%inputs. now have X(k+1)=G*X(k)+H*u(k); from system Dx=A*X+B*X
%note if we use the farmat long wo would have a more accurate H matrix

%2-3 系统的框图表示
%systems representations by nlock diagrams; Block diagrams of system can be
%in given by transfer system or defined by state space form
%in matlab uses sys to represent such system the statement:
clear all
num=;den=;
sys=tf(num,den);
sy=tf(den,num);
A=;B=;C=;D=;
sys1=ss(A,B,C,D);
%any linear invariant system may be repreented by combination of series
%connected blocks and parallel connected block and feedback-connected
%blocks.
sys11=series(sys,sys1);
sys=parallel(sys,sy);
sys=feedback(sys,sy,+1)
%note that in treating the feedback system,matlab assumed that the feedback
%was negative .if the system involves a positve feedback we need to add +1

%pole-zero cancellation ,the cancellation command minreal .this command
%performs the zoro pole cancellation does occur,the cancelled expression
%can be obtained by use ,produces the minimal_odred transfer function . the
%common factors be cancell.
sys=minreal(sys);


% 3 时域分析



%matlab approach to the state_space design of control systems
%matlab is usefull to the controllability and observability of any linear
%time_invariant system and also usefull to designing observers and observer
%controllers.
% a system is said to said be controllable at time to if it is possible to
% transfer the system from any initinal state x(t0) to any other state in a
% finite interval of time by means of an unconstrained controlvector.
%a system is said to be observable at time to if it is possible to dermine
%the state x(t0) of the system from the observation of the output over
%afinite time interval,.therefor the system is completely observable if
%every transition of the state eventually affects every element of the
%output vector

%we now shall derive the condition for completelystate controllable,without
%loss of generality,we can assume that the finial state is the orgin of the
%state space and intinial time is zero .
%and from the preceding annalysis,we can state the condition for complete state controllability
%as follows:the system given by equation is completely state controballe if
%and only if the vectors are linearly
%independent,or the n*n matrix is of rank matrix.
%from the foregoing anlysis we can state the conditions for complete
%observability as follows :;A=n*n
%is of rank n or have linerly independant column vectors.
%command
A=[0 1 0;
    0 0 1;
    -6 -11 -6];
B=.';
C=;
D=;
cont=ctrb(A,B);
a=rank(cont);
obser=obsv(A,C);
b=rank(obser);
=ss2tf(A,B,C,D);
sys=tf(num,den);
sys_min=minreal(sys);
%if rank cont of obser is less than n where n is the order of the system,the system is not controllabke
%and not observable,respectively. in terms of transfer function ,if the
%rank of ...is less than n,there is a cancellation of terms in the
%numerator and denominator of the transfer function

%6-3)pole_placement
%if the systems considered is completely state controllable ,then poles of
%the closed_loop system may be placed at any desired location by means of
%state feedback throught an approprate state feedback gain matrix.
%the present design technique begins with a determination of the desried
%closed-loop poles based on the the transient response or frequency response requiments
%such as speed damping radio and bandwith as well as steady state
%requirements,
%in this chapter wo limit our discussion on singel input and single output
%system.when the control signal is a vector quantity the state feedback
%gain matrix is not unique:>>>

%the frist step in the pole_placement design approch is to choose the
%location of the desired closed_loop poles.the most frequency useed
%approch is to choose such poles on the basis of experience in root locus
%design ,placing a domiant pair of closed loop poles and choosing.
%note that if we place the dominant closed loop poles far from the jw_axis
%so that the system response becomes very fast,the signals in the system
%becomes very large,with the result the system may be bocome nonlinear,this
%should be avioded.and high speed response requiring the large amount of
%control energy,also heavier actuator which will cost more
%example:
clc
clear all
close all
A=[0 1 0;
   0 0 1;
   -1 -5 -6;];
B=.';
%these system uses the state feedback control u=-K*X;let us the choose the
%disired closed loop poles at
s=-2+j*4;s=-2-j*4;   s=-10;
%we make this choice because we know from rom experience that such a set
%of closed loop poles will result in a reaonable or acceptable transient
%response.
%detemine the state feedback gain matrix K
syms k1 k2 k3 s
K=;
z=s*eye(size(A))-A+B*K;
z=det(z);
%compare withs=-2+j*4;s=-2-j*4;   s=-10; we can obtain K
%the second method is to use Ackermanns formula
K=()*inv()*(A^3+14*A^2+60*A+200*eye(size(A)));
%K is a compromise between the rapidity of the response of the error
%vector and the sensitivity to disturbances and messurement noises.

%(6-4)slving pole placement problems with matlab
%pole placment problems can be solved easily with matlab which has two
%commands acker and place for the computation of the feedback gain matrix
%K.the command acker is based on ackermanns formula and applies to single
%input system only.
%if the system involves multiple inputs then for a specified set of closed
%loop poles the state feedback gain matrix K is not unique and we have an
%additional freedom to choose K,,,for example one common use is to
%maximize the stability margin.the pole placement based on this method is
%called robust pole placement.use place command
%howere place command requires the multiplicity of poles in the desired
%closed loop system be no grear than the rank of B
A=[0 1 0;
   0 0 1;
   -1 -5 -6;];
B=.';
J=[-2+j*4 -2-j*4 -10];%the J is the matrix consisting of the desired closed loop poles
K=acker(A,B,J);
%the command eig(A-B*K) may be used to verfy that K thus gives the desired
%eigenvalue
a=eig(A-B*K); %which must be same to J
KK=place(A,B,J); %LQR method

%(6-5)design of state observers with matlab
%in the pole placement approach to the design of control systems we
%assumed that all state variable for feedback;
%if an abserver that estimates fewer than n state variables,where n is the
%dimension of the state vector is called a reduced order state observer
%as we shall see later state observers can be designed if and only if the
%observability condition is satisfied. In many cases the observed,state
%vector Xx is used in the state feedback to genrate the desired control
%vetor,

%dXx=A*Xx+B*u+Ke*(y-C*Xx);
%de=(A-Ke*C)*ewhere e=X-Xx;
%the problem of designing a full order observer becomes that of
%determining the observer gian matrix Ke such that the error dynamics
%difinedby equation de=(A-Ke*C)*e are asymptotically stable that with
%sufficient speed of response.
































































































































































博大广阔 发表于 2012-6-6 20:44

英语注解是我自己的。。。有点差,,

yanhunanche 发表于 2012-6-24 15:16

ddddddddddddddddddddddddddddddd

kyu16866 发表于 2012-11-9 20:39

好 ,多谢

firecat_2 发表于 2013-1-6 10:41

如果注释换成中文就更好了
页: [1]
查看完整版本: MATLAB 中控制系统命令介绍