cd V:\Cursos\Pos\Otimiza\Aulas help lqr LQR Linear-quadratic regulator design for continuous-time systems. [K,S,E] = LQR(A,B,Q,R,N) calculates the optimal gain matrix K such that the state-feedback law u = -Kx minimizes the cost function J = Integral {x'Qx + u'Ru + 2*x'Nu} dt . subject to the state dynamics x = Ax + Bu. The matrix N is set to zero when omitted. Also returned are the Riccati equation solution S and the closed-loop eigenvalues E: -1 SA + A'S - (SB+N)R (B'S+N') + Q = 0 , E = EIG(A-B*K) . See also LQRY, DLQR, LQGREG, CARE, and REG. help lqry LQRY Linear-quadratic regulator design with output weighting. [K,S,E] = LQRY(SYS,Q,R,N) calculates the optimal gain matrix K such that: * if SYS is a continuous-time system, the state-feedback law u = -Kx minimizes the cost function J = Integral {y'Qy + u'Ru + 2*y'Nu} dt . subject to the system dynamics x = Ax + Bu, y = Cx + Du * if SYS is a discrete-time system, u[n] = -Kx[n] minimizes J = Sum {y'Qy + u'Ru + 2*y'Nu} subject to x[n+1] = Ax[n] + Bu[n], y[n] = Cx[n] + Du[n]. The matrix N is set to zero when omitted. Also returned are the the solution S of the associated algebraic Riccati equation and the closed-loop eigenvalues E = EIG(A-B*K). See also LQR, LQGREG, CARE, DARE. Overloaded methods help lti/lqry.m help lqr LQR Linear-quadratic regulator design for continuous-time systems. [K,S,E] = LQR(A,B,Q,R,N) calculates the optimal gain matrix K such that the state-feedback law u = -Kx minimizes the cost function J = Integral {x'Qx + u'Ru + 2*x'Nu} dt . subject to the state dynamics x = Ax + Bu. The matrix N is set to zero when omitted. Also returned are the Riccati equation solution S and the closed-loop eigenvalues E: -1 SA + A'S - (SB+N)R (B'S+N') + Q = 0 , E = EIG(A-B*K) . See also LQRY, DLQR, LQGREG, CARE, and REG. help lqgreg --- help for lti/lqgreg.m --- LQGREG Form linear-quadratic-Gaussian (LQG) regulator RLQG = LQGREG(KEST,K) produces an LQG regulator by connecting the Kalman estimator KEST designed with KALMAN and the state-feedback gain K designed with (D)LQR or LQRY: +----------------------------+ u | | | +------+ | +--->| | x_e +----+ | | KEST |------>| -K |---+-----> u y -------->| | +----+ +------+ The resulting regulator RLQG has input y and generates the commands u = -K x_e where x_e is the Kalman state estimate based on the measurements y. This regulator should be connected to the plant using positive feedback. For discrete systems, x_e is the state estimate x[n|n-1] based on past measurements up to y[n-1]. Alternatively, RLQG = LQGREG(KEST,K,'current') forms the "current" regulator u = -K x[n|n]. RLQG = LQGREG(KEST,K,CONTROLS) handles estimators that have access to additional known plant inputs Ud. The index vector CONTROLS then specifies which estimator inputs are the controls u, and the LQG regulator has input [Ud;y]: +----------------------------+ u | | | +------+ | +--->| | x_e +----+ | Ud -------->| KEST |------>| -K |---+-----> u y -------->| | +----+ +------+ See also (D)LQR, LQRY, LQRD, KALMAN, REG, SS. help lqrd LQRD Discrete linear-quadratic regulator design from continuous cost function. [K,S,E] = LQRD(A,B,Q,R,Ts) calculates the optimal gain matrix K such that the discrete state-feedback law u[n] = -K x[n] minimizes a discrete cost function equivalent to the continuous cost function J = Integral {x'Qx + u'Ru} dt subject to the discretized state dynamics x[n+1] = Ad x[n] + Bd u[n] where [Ad,Bd] = C2D(A,B,Ts). Also returned are the discrete Riccati equation solution S and the closed-loop eigenvalues E = EIG(Ad-Bd*K). [K,S,E] = LQRD(A,B,Q,R,N,Ts) handles the more general cost function J = Integral {x'Qx + u'Ru + 2*x'Nu} dt . Algorithm: the continuous plant (A,B,C,D) and continuous weighting matrices (Q,R,N) are discretized using the sample time Ts and zero-order hold approximation. The gain matrix K is then calculated using DLQR. See also DLQR, LQR, C2D, and KALMD. help lqr LQR Linear-quadratic regulator design for continuous-time systems. [K,S,E] = LQR(A,B,Q,R,N) calculates the optimal gain matrix K such that the state-feedback law u = -Kx minimizes the cost function J = Integral {x'Qx + u'Ru + 2*x'Nu} dt . subject to the state dynamics x = Ax + Bu. The matrix N is set to zero when omitted. Also returned are the Riccati equation solution S and the closed-loop eigenvalues E: -1 SA + A'S - (SB+N)R (B'S+N') + Q = 0 , E = EIG(A-B*K) . See also LQRY, DLQR, LQGREG, CARE, and REG. A=rand(3)-eye(3)*-2 A = 2.9501 0.4860 0.4565 0.2311 2.8913 0.0185 0.6068 0.7621 2.8214 eig(A) ans = 3.6175 2.4332 2.6121 A=rand(3)-eye(3)*2 A = -1.5553 0.9218 0.4057 0.6154 -1.2618 0.9355 0.7919 0.1763 -1.0831 eig(A) ans = -0.0319 -1.9342 + 0.3097i -1.9342 - 0.3097i B=rand(3,2) B = 0.4103 0.3529 0.8936 0.8132 0.0579 0.0099 help lqr LQR Linear-quadratic regulator design for continuous-time systems. [K,S,E] = LQR(A,B,Q,R,N) calculates the optimal gain matrix K such that the state-feedback law u = -Kx minimizes the cost function J = Integral {x'Qx + u'Ru + 2*x'Nu} dt . subject to the state dynamics x = Ax + Bu. The matrix N is set to zero when omitted. Also returned are the Riccati equation solution S and the closed-loop eigenvalues E: -1 SA + A'S - (SB+N)R (B'S+N') + Q = 0 , E = EIG(A-B*K) . See also LQRY, DLQR, LQGREG, CARE, and REG. Q=eye(3)*3 Q = 3 0 0 0 3 0 0 0 3 R=eye(2) R = 1 0 0 1 help lqr LQR Linear-quadratic regulator design for continuous-time systems. [K,S,E] = LQR(A,B,Q,R,N) calculates the optimal gain matrix K such that the state-feedback law u = -Kx minimizes the cost function J = Integral {x'Qx + u'Ru + 2*x'Nu} dt . subject to the state dynamics x = Ax + Bu. The matrix N is set to zero when omitted. Also returned are the Riccati equation solution S and the closed-loop eigenvalues E: -1 SA + A'S - (SB+N)R (B'S+N') + Q = 0 , E = EIG(A-B*K) . See also LQRY, DLQR, LQGREG, CARE, and REG. [K,S,E] = LQR(A,B,Q,R) K = 0.7098 0.8974 0.6091 0.6007 0.7970 0.4748 S = 1.0693 0.2681 0.5435 0.2681 0.8598 0.3286 0.5435 0.3286 1.5970 E = -2.3815 + 0.1750i -2.3815 - 0.1750i -1.1302 help sim SIM Simulate a Simulink model SIM('model') will simulate your Simulink model using all simulation parameter dialog settings including Workspace I/O options. The SIM command also takes the following parameters. By default time, state, and output are saved to the specified left hand side arguments unless OPTIONS overrides this. If there are no left hand side arguments, then the simulation parameters dialog Workspace I/O settings are used to specify what data to log. [T,X,Y] = SIM('model',TIMESPAN,OPTIONS,UT) [T,X,Y1,...,Yn] = SIM('model',TIMESPAN,OPTIONS,UT) T : Returned time vector. X : Returned state in matrix or structure format. The state matrix contains continuous states followed by discrete states. Y : Returned output in matrix or structure format. For block diagram models this contains all root-level outport blocks. Y1,...,Yn : Can only be specified for block diagram models, where n must be the number of root-level outport blocks. Each outport will be returned in the Y1,...,Yn variables. 'model' : Name of a block diagram model. TIMESPAN : One of: TFinal, [TStart TFinal], or [TStart OutputTimes TFinal]. OutputTimes are time points which will be returned in T, but in general T will include additional time points. OPTIONS : Optional simulation parameters. This is a structure created with SIMSET using name value pairs. UT : Optional extern input. UT = [T, U1, ... Un] where T = [t1, ..., tm]' or UT is a string containing a function u=UT(t) evaluated at each time step. For table inputs, the input to the model is interpolated from UT. Specifying any right hand side argument to SIM as the empty matrix, [], will cause the default for the argument to be used. Only the first parameter is required. All defaults will be taken from the block diagram, including unspecified options. Any optional arguments specified will override the settings in the block diagram. See also SLDEBUG, SIMSET. Overloaded methods help network/sim.m help ricatti ricatti.m not found. help ric RIC Riccati residual calculation. [Kerr,Serr] = RIC(A,B,Q,R,K,S) Computes the error in the solution to the Riccati equation. Kerr is the error in the gain matrix and Serr is the residual error in the Riccati equation. -1 -1 Kerr = K-R B'S; Serr = SA + A'S - SBR B'S + Q [Kerr,Serr] = RIC(A,B,Q,R,K,S,N) computes the error in the solution to the Riccati equation with cross weighting term. -1 -1 Kerr = K-R (N'+B'S); Serr = SA + A'S - (SB+N)R (N'+B'S) + Q See also DRIC, ARE, LQE, and LQR. help lqr LQR Linear-quadratic regulator design for continuous-time systems. [K,S,E] = LQR(A,B,Q,R,N) calculates the optimal gain matrix K such that the state-feedback law u = -Kx minimizes the cost function J = Integral {x'Qx + u'Ru + 2*x'Nu} dt . subject to the state dynamics x = Ax + Bu. The matrix N is set to zero when omitted. Also returned are the Riccati equation solution S and the closed-loop eigenvalues E: -1 SA + A'S - (SB+N)R (B'S+N') + Q = 0 , E = EIG(A-B*K) . See also LQRY, DLQR, LQGREG, CARE, and REG. help lqry LQRY Linear-quadratic regulator design with output weighting. [K,S,E] = LQRY(SYS,Q,R,N) calculates the optimal gain matrix K such that: * if SYS is a continuous-time system, the state-feedback law u = -Kx minimizes the cost function J = Integral {y'Qy + u'Ru + 2*y'Nu} dt . subject to the system dynamics x = Ax + Bu, y = Cx + Du * if SYS is a discrete-time system, u[n] = -Kx[n] minimizes J = Sum {y'Qy + u'Ru + 2*y'Nu} subject to x[n+1] = Ax[n] + Bu[n], y[n] = Cx[n] + Du[n]. The matrix N is set to zero when omitted. Also returned are the the solution S of the associated algebraic Riccati equation and the closed-loop eigenvalues E = EIG(A-B*K). See also LQR, LQGREG, CARE, DARE. Overloaded methods help lti/lqry.m help lqr LQR Linear-quadratic regulator design for continuous-time systems. [K,S,E] = LQR(A,B,Q,R,N) calculates the optimal gain matrix K such that the state-feedback law u = -Kx minimizes the cost function J = Integral {x'Qx + u'Ru + 2*x'Nu} dt . subject to the state dynamics x = Ax + Bu. The matrix N is set to zero when omitted. Also returned are the Riccati equation solution S and the closed-loop eigenvalues E: -1 SA + A'S - (SB+N)R (B'S+N') + Q = 0 , E = EIG(A-B*K) . See also LQRY, DLQR, LQGREG, CARE, and REG. A=rand(3)-2*eye(3) A = -1.8611 0.6038 0.0153 0.2028 -1.7278 0.7468 0.1987 0.1988 -1.5549 eig(A) ans = -1.0530 -2.0454 + 0.1755i -2.0454 - 0.1755i B=rand(3,2) B = 0.9318 0.8462 0.4660 0.5252 0.4186 0.2026 help step STEP Step response of LTI models. STEP(SYS) plots the step response of the LTI model SYS (created with either TF, ZPK, or SS). For multi-input models, independent step commands are applied to each input channel. The time range and number of points are chosen automatically. STEP(SYS,TFINAL) simulates the step response from t=0 to the final time t=TFINAL. For discrete-time models with unspecified sampling time, TFINAL is interpreted as the number of samples. STEP(SYS,T) uses the user-supplied time vector T for simulation. For discrete-time models, T should be of the form Ti:Ts:Tf where Ts is the sample time. For continuous-time models, T should be of the form Ti:dt:Tf where dt will become the sample time for the discrete approximation to the continuous system. The step input is always assumed to start at t=0 (regardless of Ti). STEP(SYS1,SYS2,...,T) plots the step response of multiple LTI models SYS1,SYS2,... on a single plot. The time vector T is optional. You can also specify a color, line style, and marker for each system, as in step(sys1,'r',sys2,'y--',sys3,'gx'). When invoked with left-hand arguments, [Y,T] = STEP(SYS) returns the output response Y and the time vector T used for simulation. No plot is drawn on the screen. If SYS has NY outputs and NU inputs, and LT=length(T), Y is an array of size [LT NY NU] where Y(:,:,j) gives the step response of the j-th input channel. For state-space models, [Y,T,X] = STEP(SYS) also returns the state trajectory X which is an LT-by-NX-by-NU array if SYS has NX states. See also IMPULSE, INITIAL, LSIM, LTIVIEW, LTIMODELS. Overloaded methods help lti/step.m help frd/step.m help ss SS Create state-space model or convert LTI model to state space. Creation: SYS = SS(A,B,C,D) creates a continuous-time state-space (SS) model SYS with matrices A,B,C,D. The output SYS is a SS object. You can set D=0 to mean the zero matrix of appropriate dimensions. SYS = SS(A,B,C,D,Ts) creates a discrete-time SS model with sample time Ts (set Ts=-1 if the sample time is undetermined). SYS = SS creates an empty SS object. SYS = SS(D) specifies a static gain matrix D. In all syntax above, the input list can be followed by pairs 'PropertyName1', PropertyValue1, ... that set the various properties of SS models (type LTIPROPS for details). To make SYS inherit all its LTI properties from an existing LTI model REFSYS, use the syntax SYS = SS(A,B,C,D,REFSYS). Arrays of state-space models: You can create arrays of state-space models by using ND arrays for A,B,C,D above. The first two dimensions of A,B,C,D determine the number of states, inputs, and outputs, while the remaining dimensions specify the array sizes. For example, if A,B,C,D are 4D arrays and their last two dimensions have lengths 2 and 5, then SYS = SS(A,B,C,D) creates the 2-by-5 array of SS models SYS(:,:,k,m) = SS(A(:,:,k,m),...,D(:,:,k,m)), k=1:2, m=1:5. All models in the resulting SS array share the same number of outputs, inputs, and states. SYS = SS(ZEROS([NY NU S1...Sk])) pre-allocates space for an SS array with NY outputs, NU inputs, and array sizes [S1...Sk]. Conversion: SYS = SS(SYS) converts an arbitrary LTI model SYS to state space, i.e., computes a state-space realization of SYS. SYS = SS(SYS,'min') computes a minimal realization of SYS. See also LTIMODELS, DSS, RSS, DRSS, SSDATA, LTIPROPS, TF, ZPK, FRD. s1=ss(A,B,eye(3),zero(3,2)) ??? No appropriate methods for function zero. s1=ss(A,B,eye(3),zeros(3,2)) a = x1 x2 x3 x1 -1.8611 0.60379 0.015274 x2 0.20277 -1.7278 0.74679 x3 0.19872 0.19881 -1.5549 b = u1 u2 x1 0.93181 0.84622 x2 0.46599 0.52515 x3 0.41865 0.20265 c = x1 x2 x3 y1 1 0 0 y2 0 1 0 y3 0 0 1 d = u1 u2 y1 0 0 y2 0 0 y3 0 0 Continuous-time model. s1=ss(A,B) ??? Error using ==> ss/ss Undefined C and D matrices. s1=ss(A,B,eye(3),zeros(3,2)) a = x1 x2 x3 x1 -1.8611 0.60379 0.015274 x2 0.20277 -1.7278 0.74679 x3 0.19872 0.19881 -1.5549 b = u1 u2 x1 0.93181 0.84622 x2 0.46599 0.52515 x3 0.41865 0.20265 c = x1 x2 x3 y1 1 0 0 y2 0 1 0 y3 0 0 1 d = u1 u2 y1 0 0 y2 0 0 y3 0 0 Continuous-time model. step(s1) help lqr LQR Linear-quadratic regulator design for continuous-time systems. [K,S,E] = LQR(A,B,Q,R,N) calculates the optimal gain matrix K such that the state-feedback law u = -Kx minimizes the cost function J = Integral {x'Qx + u'Ru + 2*x'Nu} dt . subject to the state dynamics x = Ax + Bu. The matrix N is set to zero when omitted. Also returned are the Riccati equation solution S and the closed-loop eigenvalues E: -1 SA + A'S - (SB+N)R (B'S+N') + Q = 0 , E = EIG(A-B*K) . See also LQRY, DLQR, LQGREG, CARE, and REG. Q=3*eye(3) Q = 3 0 0 0 3 0 0 0 3 R=eye(3) R = 1 0 0 0 1 0 0 0 1 [K,S,E] = LQR(A,B,Q,R) ??? Error using ==> lqr The R matrix must be square with as many columns as B. R=eye(2) R = 1 0 0 1 [K,S,E] = LQR(A,B,Q,R) K = 0.5831 0.4362 0.4276 0.5383 0.4507 0.2330 S = 0.6345 0.0176 -0.0392 0.0176 0.7764 0.1385 -0.0392 0.1385 0.9546 E = -3.0085 -1.7921 -2.0083 eig(S) ans = 0.6186 0.7150 1.0319 Ak=A-B*K Ak = -2.8599 -0.1841 -0.5803 -0.3516 -2.1678 0.4252 -0.1545 -0.0751 -1.7811 eig(Ak) ans = -3.0085 -1.7921 -2.0083 help sim SIM Simulate a Simulink model SIM('model') will simulate your Simulink model using all simulation parameter dialog settings including Workspace I/O options. The SIM command also takes the following parameters. By default time, state, and output are saved to the specified left hand side arguments unless OPTIONS overrides this. If there are no left hand side arguments, then the simulation parameters dialog Workspace I/O settings are used to specify what data to log. [T,X,Y] = SIM('model',TIMESPAN,OPTIONS,UT) [T,X,Y1,...,Yn] = SIM('model',TIMESPAN,OPTIONS,UT) T : Returned time vector. X : Returned state in matrix or structure format. The state matrix contains continuous states followed by discrete states. Y : Returned output in matrix or structure format. For block diagram models this contains all root-level outport blocks. Y1,...,Yn : Can only be specified for block diagram models, where n must be the number of root-level outport blocks. Each outport will be returned in the Y1,...,Yn variables. 'model' : Name of a block diagram model. TIMESPAN : One of: TFinal, [TStart TFinal], or [TStart OutputTimes TFinal]. OutputTimes are time points which will be returned in T, but in general T will include additional time points. OPTIONS : Optional simulation parameters. This is a structure created with SIMSET using name value pairs. UT : Optional extern input. UT = [T, U1, ... Un] where T = [t1, ..., tm]' or UT is a string containing a function u=UT(t) evaluated at each time step. For table inputs, the input to the model is interpolated from UT. Specifying any right hand side argument to SIM as the empty matrix, [], will cause the default for the argument to be used. Only the first parameter is required. All defaults will be taken from the block diagram, including unspecified options. Any optional arguments specified will override the settings in the block diagram. See also SLDEBUG, SIMSET. Overloaded methods help network/sim.m help linsim LINSIM Simulink 1.x LINSIM integration algorithm. LINSIM is obsolete and will be eliminated in future versions. Use SIM instead. LINSIM is mapped to the Simulink 3 'ode45' algorithm. See also SIM. help sim SIM Simulate a Simulink model SIM('model') will simulate your Simulink model using all simulation parameter dialog settings including Workspace I/O options. The SIM command also takes the following parameters. By default time, state, and output are saved to the specified left hand side arguments unless OPTIONS overrides this. If there are no left hand side arguments, then the simulation parameters dialog Workspace I/O settings are used to specify what data to log. [T,X,Y] = SIM('model',TIMESPAN,OPTIONS,UT) [T,X,Y1,...,Yn] = SIM('model',TIMESPAN,OPTIONS,UT) T : Returned time vector. X : Returned state in matrix or structure format. The state matrix contains continuous states followed by discrete states. Y : Returned output in matrix or structure format. For block diagram models this contains all root-level outport blocks. Y1,...,Yn : Can only be specified for block diagram models, where n must be the number of root-level outport blocks. Each outport will be returned in the Y1,...,Yn variables. 'model' : Name of a block diagram model. TIMESPAN : One of: TFinal, [TStart TFinal], or [TStart OutputTimes TFinal]. OutputTimes are time points which will be returned in T, but in general T will include additional time points. OPTIONS : Optional simulation parameters. This is a structure created with SIMSET using name value pairs. UT : Optional extern input. UT = [T, U1, ... Un] where T = [t1, ..., tm]' or UT is a string containing a function u=UT(t) evaluated at each time step. For table inputs, the input to the model is interpolated from UT. Specifying any right hand side argument to SIM as the empty matrix, [], will cause the default for the argument to be used. Only the first parameter is required. All defaults will be taken from the block diagram, including unspecified options. Any optional arguments specified will override the settings in the block diagram. See also SLDEBUG, SIMSET. Overloaded methods help network/sim.m help ode45 ODE45 Solve non-stiff differential equations, medium order method. [T,Y] = ODE45('F',TSPAN,Y0) with TSPAN = [T0 TFINAL] integrates the system of differential equations y' = F(t,y) from time T0 to TFINAL with initial conditions Y0. 'F' is a string containing the name of an ODE file. Function F(T,Y) must return a column vector. Each row in solution array Y corresponds to a time returned in column vector T. To obtain solutions at specific times T0, T1, ..., TFINAL (all increasing or all decreasing), use TSPAN = [T0 T1 ... TFINAL]. [T,Y] = ODE45('F',TSPAN,Y0,OPTIONS) solves as above with default integration parameters replaced by values in OPTIONS, an argument created with the ODESET function. See ODESET for details. Commonly used options are scalar relative error tolerance 'RelTol' (1e-3 by default) and vector of absolute error tolerances 'AbsTol' (all components 1e-6 by default). [T,Y] = ODE45('F',TSPAN,Y0,OPTIONS,P1,P2,...) passes the additional parameters P1,P2,... to the ODE file as F(T,Y,FLAG,P1,P2,...) (see ODEFILE). Use OPTIONS = [] as a place holder if no options are set. It is possible to specify TSPAN, Y0 and OPTIONS in the ODE file (see ODEFILE). If TSPAN or Y0 is empty, then ODE45 calls the ODE file [TSPAN,Y0,OPTIONS] = F([],[],'init') to obtain any values not supplied in the ODE45 argument list. Empty arguments at the end of the call list may be omitted, e.g. ODE45('F'). As an example, the commands options = odeset('RelTol',1e-4,'AbsTol',[1e-4 1e-4 1e-5]); ode45('rigidode',[0 12],[0 1 1],options); solve the system y' = rigidode(t,y) with relative error tolerance 1e-4 and absolute tolerances of 1e-4 for the first two components and 1e-5 for the third. When called with no output arguments, as in this example, ODE45 calls the default output function ODEPLOT to plot the solution as it is computed. ODE45 can solve problems M(t,y)*y' = F(t,y) with a mass matrix M that is nonsingular. Use ODESET to set Mass to 'M', 'M(t)', or 'M(t,y)' if the ODE file is coded so that F(T,Y,'mass') returns a constant, time-dependent, or time- and state-dependent mass matrix, respectively. The default value of Mass is 'none'. See FEM1ODE, FEM2ODE, or BATONODE. ODE15S and ODE23T can solve problems with singular mass matrices. [T,Y,TE,YE,IE] = ODE45('F',TSPAN,Y0,OPTIONS) with the Events property in OPTIONS set to 'on', solves as above while also locating zero crossings of an event function defined in the ODE file. The ODE file must be coded so that F(T,Y,'events') returns appropriate information. See ODEFILE for details. Output TE is a column vector of times at which events occur, rows of YE are the corresponding solutions, and indices in vector IE specify which event occurred. See also ODEFILE and other ODE solvers: ODE23, ODE113, ODE15S, ODE23S, ODE23T, ODE23TB options handling: ODESET, ODEGET output functions: ODEPLOT, ODEPHAS2, ODEPHAS3, ODEPRINT odefile examples: ORBITODE, ORBT2ODE, RIGIDODE, VDPODE s2=ss(Ak,0,eye(3),0) ??? Error using ==> ss/ss Error using ==> C:\Apps\Matlab\toolbox\control\@ss\private\abcdechk The A and B matrices must have the same number of rows. s2=ss(Ak,zeros(3,3),eye(3),0) a = x1 x2 x3 x1 -2.8599 -0.18409 -0.5803 x2 -0.35161 -2.1678 0.42519 x3 -0.15445 -0.075146 -1.7811 b = u1 u2 u3 x1 0 0 0 x2 0 0 0 x3 0 0 0 c = x1 x2 x3 y1 1 0 0 y2 0 1 0 y3 0 0 1 d = u1 u2 u3 y1 0 0 0 y2 0 0 0 y3 0 0 0 Continuous-time model. [t,y]=ode45(ss,[0 100],[1 1 1]) ??? Error using ==> ode45 First argument must be a single-quoted string. See ODE45. [t,y]=sim(ss,[0 100],[1 1 1]) ??? Error using ==> sim 'model' parameter must be a string. help sim SIM Simulate a Simulink model SIM('model') will simulate your Simulink model using all simulation parameter dialog settings including Workspace I/O options. The SIM command also takes the following parameters. By default time, state, and output are saved to the specified left hand side arguments unless OPTIONS overrides this. If there are no left hand side arguments, then the simulation parameters dialog Workspace I/O settings are used to specify what data to log. [T,X,Y] = SIM('model',TIMESPAN,OPTIONS,UT) [T,X,Y1,...,Yn] = SIM('model',TIMESPAN,OPTIONS,UT) T : Returned time vector. X : Returned state in matrix or structure format. The state matrix contains continuous states followed by discrete states. Y : Returned output in matrix or structure format. For block diagram models this contains all root-level outport blocks. Y1,...,Yn : Can only be specified for block diagram models, where n must be the number of root-level outport blocks. Each outport will be returned in the Y1,...,Yn variables. 'model' : Name of a block diagram model. TIMESPAN : One of: TFinal, [TStart TFinal], or [TStart OutputTimes TFinal]. OutputTimes are time points which will be returned in T, but in general T will include additional time points. OPTIONS : Optional simulation parameters. This is a structure created with SIMSET using name value pairs. UT : Optional extern input. UT = [T, U1, ... Un] where T = [t1, ..., tm]' or UT is a string containing a function u=UT(t) evaluated at each time step. For table inputs, the input to the model is interpolated from UT. Specifying any right hand side argument to SIM as the empty matrix, [], will cause the default for the argument to be used. Only the first parameter is required. All defaults will be taken from the block diagram, including unspecified options. Any optional arguments specified will override the settings in the block diagram. See also SLDEBUG, SIMSET. Overloaded methods help network/sim.m help step STEP Step response of LTI models. STEP(SYS) plots the step response of the LTI model SYS (created with either TF, ZPK, or SS). For multi-input models, independent step commands are applied to each input channel. The time range and number of points are chosen automatically. STEP(SYS,TFINAL) simulates the step response from t=0 to the final time t=TFINAL. For discrete-time models with unspecified sampling time, TFINAL is interpreted as the number of samples. STEP(SYS,T) uses the user-supplied time vector T for simulation. For discrete-time models, T should be of the form Ti:Ts:Tf where Ts is the sample time. For continuous-time models, T should be of the form Ti:dt:Tf where dt will become the sample time for the discrete approximation to the continuous system. The step input is always assumed to start at t=0 (regardless of Ti). STEP(SYS1,SYS2,...,T) plots the step response of multiple LTI models SYS1,SYS2,... on a single plot. The time vector T is optional. You can also specify a color, line style, and marker for each system, as in step(sys1,'r',sys2,'y--',sys3,'gx'). When invoked with left-hand arguments, [Y,T] = STEP(SYS) returns the output response Y and the time vector T used for simulation. No plot is drawn on the screen. If SYS has NY outputs and NU inputs, and LT=length(T), Y is an array of size [LT NY NU] where Y(:,:,j) gives the step response of the j-th input channel. For state-space models, [Y,T,X] = STEP(SYS) also returns the state trajectory X which is an LT-by-NX-by-NU array if SYS has NX states. See also IMPULSE, INITIAL, LSIM, LTIVIEW, LTIMODELS. Overloaded methods help lti/step.m help frd/step.m help initial INITIAL Initial condition response of state-space models. INITIAL(SYS,X0) plots the undriven response of the state-space model SYS with initial condition X0 on the states. This response is characterized by the equations . Continuous time: x = A x , y = C x , x(0) = x0 Discrete time: x[k+1] = A x[k], y[k] = C x[k], x[0] = x0 . The time range and number of points are chosen automatically. INITIAL(SYS,X0,TFINAL) simulates the time response from t=0 to the final time t=TFINAL. For discrete-time models with unspecified sample time, TFINAL should be the number of samples. INITIAL(SYS,X0,T) specifies a time vector T to be used for simulation. For discrete systems, T should be of the form 0:Ts:Tf where Ts is the sample time. For continuous-time models, T should be of the form 0:dt:Tf where dt will become the sample time of a discrete approximation of the continuous model. INITIAL(SYS1,SYS2,...,X0,T) plots the response of multiple LTI models SYS1,SYS2,... on a single plot. The time vector T is optional. You can also specify a color, line style, and marker for each system, as in initial(sys1,'r',sys2,'y--',sys3,'gx',x0). When invoked with left hand arguments, [Y,T,X] = INITIAL(SYS,X0) returns the output response Y, the time vector T used for simulation, and the state trajectories X. No plot is drawn on the screen. The matrix Y has LENGTH(T) rows and as many columns as outputs in SYS. Similarly, X has LENGTH(T) rows and as many columns as states. See also IMPULSE, STEP, LSIM, LTIVIEW, LTIMODELS. Overloaded methods help lti/initial.m help frd/initial.m initial(s2,[1 1 1]) s3=ss(A,0,eye(3),0) ??? Error using ==> ss/ss Error using ==> C:\Apps\Matlab\toolbox\control\@ss\private\abcdechk The A and B matrices must have the same number of rows. s3=ss(A,zeros(3),eye(3),0) a = x1 x2 x3 x1 -1.8611 0.60379 0.015274 x2 0.20277 -1.7278 0.74679 x3 0.19872 0.19881 -1.5549 b = u1 u2 u3 x1 0 0 0 x2 0 0 0 x3 0 0 0 c = x1 x2 x3 y1 1 0 0 y2 0 1 0 y3 0 0 1 d = u1 u2 u3 y1 0 0 0 y2 0 0 0 y3 0 0 0 Continuous-time model. initial(s3,[1 1 1]) hold; Current plot held initial(s2,[1 1 1]) ??? Error using ==> response/get Invalid property name "SettlingTime". Error in ==> C:\Apps\Matlab\toolbox\control\ltiplot.m (LocalCheckOptions) On line 381 ==> if strcmp(get(RespObj,'SettlingTime'),'on'); Error in ==> C:\Apps\Matlab\toolbox\control\ltiplot.m On line 300 ==> RespObj = LocalCheckOptions(plottype,RespObj,[NumOldSys+1:NumOldSys+length(sys)]); Error in ==> C:\Apps\Matlab\toolbox\control\@lti\initial.m On line 211 ==> InitRespObj = ltiplot('initial',sys(1:nsys),PlotAxes,Ydata,tvecs(1:nsys),PlotStyle(1:nsys),... clc quit