matlab gives my answer inverted
Show older comments
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 Comments
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)
Maria Cinthia
on 23 Oct 2023
Maria Cinthia
on 23 Oct 2023
Answers (1)
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))
%% 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)
%% Test if the transformed state-space yields the same transfer function
Gtf = tf(sys)
%% Step response
step(sys), grid on
Categories
Find more on Time-Domain Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
