tf2ss in Matlab to Scilab

337 views
Skip to first unread message

jatbakar

unread,
Jan 18, 2005, 9:07:39 PM1/18/05
to
hello all, I am new to this group and and a beginner to Scilab. I am
doing a project translating a Matlab program to Scilab.

I'm having trouble dealing with the tf2ss function. I am not able to
get the same results for the same transfer function in Scilab as I do
in Matlab. Would appreciate if anyone can help me or spot any mistakes
I have made.

MATLAB code
% for transfer function (2s+1)/(s^2 +4s +4)
[A,B,C,D]= tf2ss([0 2 1], [1 4 4])
A=[-4 -4; 1 0] B=[1;0] C=[2 1] D=0

SCILAB
num=poly([1 2 0], 's', 'c');
den =poly([4 4 1],'s','c');
H=num/den;
tf2ss(H)
A=[-4.4 -1.8; 3.2 0.4] B=[-1.55; 0.77] C=[-1.29 -0] D=0
Once again thanks

Tim Wescott

unread,
Jan 19, 2005, 12:38:16 PM1/19/05
to
For any given transfer function expressed as a ratio of polynomials
there are an infinite number of different state-space implementations.
Matlab is doing it in an easy-to-code, simpleminded way. Scilab is
doing something more; hopefully it's giving you a better-conditioned
system that what you're getting from Matlab.

You should be able to plug both realizations into a syslin and get the
same thing out with ss2tf.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

jatbakar

unread,
Jan 25, 2005, 12:51:55 AM1/25/05
to
hello sorry, just a little slow,
this means that there is nothing wrong with the code, and there is
nothing wrong wth answers given by Scilab.
it is just giving one of many "correct" solutions?
Should i be reading up more on state space theory?
Thank you for your reply

Tim Wescott

unread,
Jan 25, 2005, 1:14:18 AM1/25/05
to
jatbakar wrote:

Probably. I can't give you a good reference on deriving the ideal
state-space representation of a transfer function -- first because it
varies depending on what you're trying to do, and second because I don't
know one myself.

jatbakar

unread,
Feb 10, 2005, 11:03:09 PM2/10/05
to
Thanks for your help Tim. Will get this figured out soon! I hope

ayush singhal

unread,
Feb 14, 2021, 6:02:42 PM2/14/21
to
yes, there is nothing wrong with your code. Even I also stuck at the same point but later got to know there might be more results but if you do reverse(I mean to apply ss2tf), you would get the same transfer function.
Thanks.
Reply all
Reply to author
Forward
0 new messages