ControlDesign
ComputeQR
compute the Q, R, and N matrices used in an LQR design based on a desired time constant of the closed-loop system
Calling Sequence
Parameters
Options
Description
Examples
ComputeQR(sys, Tc, opts)
sys
-
System; system object
Tc
And(positive, numeric); desired closed-loop time constant (in seconds)
opts
(optional) equation(s) of the form option = value; specify options for the ComputeQR command
computeN = truefalse
True means include the N weighting matrix in the returned record. The default is false.
parameters = {list, set}(name = complexcons)
Specifies numeric values for the parameters of sys. These values override any parameters previously specified for sys. The numeric value on the right-hand side of each equation is substituted for the name on the left-hand side in the sys equations. The default is the value of sys given by DynamicSystems:-SystemOptions(parameters).
The ComputeQR command returns a record containing the Q and R weighting matrices needed by the LQR command. Optionally, the cross-coupling matrix N (weighting on the state-input term in the quadratic cost function) is included in the returned record to be used with the corresponding option of the LQR command.
The computation of the weighting matrices is based on the desired time constant, Tc (seconds), of the closed-loop system.
The system sys is a continuous or discrete-time linear system object created using the DynamicSystems package. The system object must be in state-space (SS) form. The state-space system can be either single-input/single-output (SISO) or multiple-input/multiple-output (MIMO).
The ComputeQR command invokes the ReduceSystem command to remove the structural uncontrollable states of sys which may arise from using the Subsystem command before ComputeQR. The computed weighting matrices are obtained based in the reduced system (when applicable).
with⁡ControlDesign:
with⁡DynamicSystems:
Here is a state-space system corresponding to a DC motor model:
sys_a≔Matrix⁡−dJ,KJ,0,−KL,−RL,0,1,0,0:
sys_b≔Matrix⁡0,1J,1L,0,0,0:
sys_c≔Matrix⁡0,1,0,1,0,0,0,0,1:
sys_d≔Matrix⁡0,0,0,0,0,0:
sys≔StateSpace⁡sys_a,sys_b,sys_c,sys_d,inputvariable=V⁡t,T⁡t,outputvariable=i_out⁡t,omega_out⁡t,theta_out⁡t,statevariable=ω⁡t,i⁡t,θ⁡t:
PrintSystem⁡sys
State Spacecontinuous3 output(s); 2 input(s); 3 state(s)inputvariable=V⁡t,T⁡toutputvariable=i_out⁡t,omega_out⁡t,theta_out⁡tstatevariable=ω⁡t,i⁡t,θ⁡ta=−dJKJ0−KL−RL0100b=01J1L000c=010100001d=000000
The numeric values of the model parameters are as follows:
params≔J=0.01,K=0.01,L=0.5,R=1,d=0.1:
Extract a subsystem with the desired input and output.
subsys≔Subsystem⁡sys,1,2
subsys≔State Spacecontinuous1 output(s); 1 input(s); 3 state(s)inputvariable=V⁡toutputvariable=omega_out⁡tstatevariable=ω⁡t,i⁡t,θ⁡t
Compute the weighting Matrices Q and R for a desired time constant of 1 second:
τ≔1:
QR≔ComputeQR⁡subsys,τ,parameters=params
QR≔Record⁡Q=1.0.0.0.0.0.0.0.0.,R=0.00804031799261397
Use the previous result to compute the state feedback gain:
Kc≔LQR⁡subsys,QR:-Q,QR:-R,parameters=params
Kc≔0.9634507842906180.4012318809856630
Optionally, compute the weighting Matrix N:
QRN≔ComputeQR⁡subsys,τ,computeN=true,parameters=params
QRN≔Record⁡Q=1.0.0.0.0.0.0.0.0.,R=0.00804031799261397,N=0.0.0.
Use matrices Q, R, and N to compute the state feedback gain. In this case, N is a zero Matrix, so the result is the same as before:
Kc≔LQR⁡subsys,QRN:-Q,QRN:-R,N=QRN:-N,parameters=params
See Also
ControlDesign[LQR]
ControlDesign[LQRContinuous]
ControlDesign[LQRDiscrete]
Download Help Document