How i can get state space model from transfer function?

Hello, I tried alot with the code you can see in the picture. But it doesn`t work. I want to know if Matlab dosen`t support the function of tf2ss or I just have a mistake.
[code]
num = [0 0 0 5];
den = [1 6 5 0];
[A, B, C, D] = tf2ss(num,den)
[Error message]
Execution of script tf2ss as a function is not supported:
Error in tf2ss (line 6)
[A, B, C, D] = tf2ss(num,den)
Thank you for reading my question and if you know the answer, please leave a comment :)

 Akzeptierte Antwort

Star Strider
Star Strider am 17 Jun. 2021

0 Stimmen

Apparently you named a script ‘tf2ss’. This overshadows the tf2ss function.
The solution is to re-name the script to something that is meaningful and that does not overshadow MATLAB functions.

6 Kommentare

상준 안
상준 안 am 17 Jun. 2021
Bearbeitet: 상준 안 am 17 Jun. 2021
Thank you for answering :)
Re-name the script to something means I cant use the text 'tf2ss' in Editor because of the name of function already exist, right? But I cant understand, how I can get the s.s.m from t.f without naming tf2ss in the script.
In youtube or help section in Matlab, there are some examples that use the 'tf2ss' in their script. I dont know what`s the difference between theirs and mine.
Maybe I cant understand the difference between the script and function.
Can you give me a simple example of renaming the the script 'tf2ss' to something.
Thank you for answering my question again :)
Name the script something like ‘tf2ss_demo’.
Then run the posted code from it, using the tf2ss function.
상준 안
상준 안 am 17 Jun. 2021
Bearbeitet: 상준 안 am 17 Jun. 2021
\
To get S.S.M from T.F, I should use the tf2ss function. And I understand tf2ss in my script overshadows the tf2ss function. But how can I do without naming tf2ss in the script 😥
If I rename the tf2ss to something, Matlab cant recognize it.. I`m so sorry for not to understading your good advice.😓
I have apparently not made myself clear.
Please see the attached file. It is named ‘tf2ss_demo.m’ and it contains:
% tf2ss_demo.m
s = tf('s');
Htf = [(2*s+3); (s^2+2*s+1)] / (s^2+0.4*s+1)
b = Htf.Numerator
a = Htf.Denominator
[A,B,C,D] = tf2ss(cell2mat(b),cell2mat(a(1))) % Signal Processing Toolbox
Hss = ss(Htf) % Control System Toolbox
Import the file to your MATLAB user directory, then run it.
.
Thank u so much :)
As always, my pleasure!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Hilfe-Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by