matlab gives my answer inverted

my answer for A should be [0 1 -0.75,-0.300]
num=1;
den=[12.5 3.75 9.375];
[A,B,C,D]=tf2ss(num,den);
sys=tf(num, den);
step(sys)
grid
title('Step response', 'Color','blue')

3 comentarios

hello
The state space realization of a transfer function is not unique. In fact, there are infinitely many state space realizations to choose from, but each SS realization has the same transfer function
back to your code,seems to me A is matching your expectations
what result do you get ?
num=1;
den=[12.5 3.75 9.375];
[A,B,C,D]=tf2ss(num,den)
A = 2×2
-0.3000 -0.7500 1.0000 0
B = 2×1
1 0
C = 1×2
0 0.0800
D = 0
Maria Cinthia
Maria Cinthia el 23 de Oct. de 2023
Hi, thank you and Yes I do get that answer but according to my hand written work it should be 0 1 -0.75,-0.3 for A
Maria Cinthia
Maria Cinthia el 23 de Oct. de 2023
Thanks another question I have is if state space isn’t unique, does it make sense that Matlab would find the same numerical values but would flip both the rows and the columns for A and the rows on B.
And for C, you take the inverse laplace of 1, which should result in the Dirac delta function. Is there a reason Matlab returns 0.08?

Iniciar sesión para comentar.

Respuestas (1)

Sam Chak
Sam Chak el 23 de Oct. de 2023
It sounds like you're looking for a state-space realization in the Controllable Canonical Form. If that's the case, you can follow these simple steps using the compreal() command. It's also possible to achieve this by cleverly manipulating matrix operations without relying on the canon() or compreal() functions.
%% Plant Transfer Function
num = 1;
den = [12.5 3.75 9.375];
Gp = minreal(tf(num, den))
Gp = 0.08 ------------------ s^2 + 0.3 s + 0.75 Continuous-time transfer function.
%% Companion Canonical Form
csys = compreal(Gp, "c"); % introduced in R2023b release
%% Controllable Canonical Form transformation
A = csys.A';
B = csys.C';
C = csys.B';
D = 0*C*B;
sys = ss(A, B, C, D)
sys = A = x1 x2 x1 0 1 x2 -0.75 -0.3 B = u1 x1 0 x2 0.08 C = x1 x2 y1 1 0 D = u1 y1 0 Continuous-time state-space model.
%% Test if the transformed state-space yields the same transfer function
Gtf = tf(sys)
Gtf = 0.08 ------------------ s^2 + 0.3 s + 0.75 Continuous-time transfer function.
%% Step response
step(sys), grid on

Productos

Versión

R2023b

Etiquetas

Preguntada:

el 23 de Oct. de 2023

Comentada:

el 23 de Oct. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by