www.gusucode.com > control 案例程序 matlab源码代码 > control/ControlSystemModelingWithModelObjectsExample.m
%% Control System Modeling with Model Objects % Model objects can represent individual components of a control % architecture, such as the plant, actuators, sensors, or controllers. You % can connect model objects to build aggregate models of block diagrams % that represent the combined response of multiple elements. %% % For example, the following control system contains a prefilter _F_, % a plant _G_, and a controller _C_, arranged in a single-loop configuration. % The model also includes a representation of sensor dynamics, _S_. %% % % <<../architecture.png>> % %% % You can represent each of the components as a model object. You do not % need to use the same type of model object for each component. For % example, represent the plant _G_ as a zero-pole-gain (|zpk|) model with a % double pole at |s| = -1; _C_ as a PID controller, and _F_ and _S_ as % transfer functions: % Copyright 2015 The MathWorks, Inc. G = zpk([],[-1,-1],1); C = pid(2,1.3,0.3,0.5); S = tf(5,[1 4]); F = tf(1,[1 1]); %% % You can then combine these elements build models that represent your % control system or the control system as a whole. For example, create the % open-loop response _SGC_: open_loop = S*G*C; %% % To build a model of the unfiltered closed-loop response, use the % |feedback| command: T = feedback(G*C,S); %% % To model the entire closed-loop system response from _r_ to _y_, % combine _T_ with the filter transfer function: Try = T*F; %% % The results |open_loop|, |T|, and |Try| are also linear model objects. % You can operate on them with Control System Toolbox(TM) control % design and analysis commands. For example, plot the step response % of the entire system: stepplot(Try) %% % When you combine Numeric LTI models, the resulting Numeric LTI model % represents the aggregate system. The resulting model does not retain the % original data from the combined components. For example, |T| does not % separately keep track of the dynamics of the components % |G|, |C|, and |S| that are combined to create |T|.