change state model to transfer function and change from continuous model to discrete model

4 visualizaciones (últimos 30 días)
this is my code
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);
];
% 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);
% Matrix S to find
svar = sym('s',[1 16]);
S = [svar(1:4); svar(5:8); svar(9:12); svar(13:16)];
display(S);
% 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 my model from state space to transfer function
step(tf(ss(A,B(:,1),C,W(:,1))))
i get the error like this
Error using ss (line 274)
The value of the "a" property must be a numeric array without any Inf's or NaN's.
Error in AREtrial3 (line 87)
step(tf(ss(A,B(:,1),C,W(:,1))))
after i get the Transfer function i want convert my model from continuous to discrete because i need find S using idare
I have tried using solve, vpasolve, linsolve but the result is struct with fields
Sol_S =
struct with fields:
s1: [0×1 sym]
s2: [0×1 sym]
s3: [0×1 sym]
s4: [0×1 sym]
s5: [0×1 sym]
s6: [0×1 sym]
s7: [0×1 sym]
s8: [0×1 sym]
s9: [0×1 sym]
s10: [0×1 sym]
s11: [0×1 sym]
s12: [0×1 sym]
s13: [0×1 sym]
s14: [0×1 sym]
s15: [0×1 sym]
s16: [0×1 sym]
an i have try with icare toolbox same
X1 =
[]
K1 =
[]
L1 =
0
0
-0.3134
-1.0087
X is S
K is matriks control
L is eigenvalue closed loop
I need the S matriks to find K matriks for LQR. if the eigenvalue from S matrix is positive i get K matriks. But the problem i have tried many ways still doesn't get the eigenvalue all positif

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 15 de Jun. de 2020
A and B are symbolic matrices. You need to convert them to double before passing to ss(). Try following lines of code.
ss_model = ss(double(A),double(B(:,1)),C,W(:,1));
tf_model = tf(ss_model);
step(tf_model)
  24 comentarios
Ivan Dwi Putra
Ivan Dwi Putra el 25 de Jun. de 2020
if i don't want to change to tf first, can i change directly from continuous to discrete?my model is in the form of state space xdot = Ax + Bu?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrix Computations en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by