Change Continuous State Space MIMO Model to Discrete State Space MIMO Model without Change to Transfer Function and Using idare Function to find S matrix, K matrix and eigen value S Matrix

4 views (last 30 days)
this is my code for my system model
clear; close; clc;
syms a1_head a2_head b hstar
%Parameter Massa
m1 = 8095; % massa train set 1 dalam kg
m2 = 8500; % massa train set 2 dalam kg
g = 10;
c_0_1 = 0.01176;
c_1_1 = 0.00077616;
c_2_1 = 4.48 ;
c_0_2 = 0.01176 ;
c_1_2 = 0.00077616;
c_2_2 = 4.48;
v_0 = 300;
hstar = 120;
a_1 = -1./m1.*(c_1_1 + 2.*c_2_1.*v_0);
a_2 = -1./m2.*(c_1_2 + 2.*c_2_2.*v_0);
a_1_head = 1-(a_1.*hstar);
a_2_head = 1-(a_2.*hstar);
b = 1;
% Model data
A = sym(zeros(4,4));
A(1,2) = a_1_head;
A(3,2) = (a_2_head) - 1;
A(3,4) = a_2_head;
display(A);
B = sym(zeros(4,2));
B(1,1) = -b*hstar;
B(2,1) = b;
B(3,2) = -b*hstar;
B(4,1) = -b;
B(4,2) = b;
display(B);
C = [1 0 0 0;
0 1 0 0;
0 0 1 0;
0 0 0 1];
p_1 = -1./m1.*(c_0_1 - c_2_1.*(v_0).^2);
p_2 = -1./m2.*(c_0_2 - c_2_2.*(v_0).^2);
W = [((a_1 - 1).*v_0) - (p_1.*hstar);
0;
((a_2 - 1).*v_0) - (p_2.*hstar);
((a_1 - 1).*v_0) - (p_1.*hstar);
];
This is Q and R matrics
% Q and R matrices for ARE
Q = sym(eye(4)); display(Q);
R = sym(zeros(2,2)); R(1,:) = [1 2]; R(2,:) = [2 3]; display(R);
This is S matrix I want to find
% Matrix S to find
svar = sym('s',[1 16]);
S = [svar(1:4); svar(5:8); svar(9:12); svar(13:16)];
display(S);
This is Algebra Ricatti Equation
% LHS of ARE: A'*S + S*A' - S*B*Rinv*B'*S
left_ARE = transpose(A)*S + S*A - S*B*inv(R)*transpose(B)*S;
display(left_ARE);
% RHS of ARE: -Q
right_ARE = -Q;
display(right_ARE);
I want to change to discrete state space model
ss_model = ss(double(A),double(B(:,1)),C,W(:,1));
dt = 1 ;
d_sys = c2d(ss_model,dt);
is that true use this code?
from d_sys code i get
d_sys =
A =
x1 x2 x3 x4
x1 1 40.85 0 0
x2 0 1 0 0
x3 0 37.95 1 38.95
x4 0 0 0 1
B =
u1
x1 -99.58
x2 1
x3 -0.5
x4 -1
C =
x1 x2 x3 x4
y1 1 0 0 0
y2 0 1 0 0
y3 0 0 1 0
y4 0 0 0 1
D =
u1
y1 -6377
y2 0
y3 -6087
y4 -6377
Sample time: 1 seconds
Discrete-time state-space model.
now i wan to use idare to find X(S matrix),K matrix in lqr,L(Eigen value S matrix) using idare function
how i use idare function using A,B,C,D in discrete state space model?
from the d_sys my B matrix is weird because my B matrix become 4x1 different from my model 4x2

Answers (0)

Categories

Find more on Matrix Computations in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!