Trying to use simplify with an equation equal to zero.

19 views (last 30 days)
I'm sorry if this has been asked previously. I've tried searching and can't seem to find this scenario though I can't imagine I'm the first person to have this issue. Here's the code I'm working with, this is for a control systems problem...
syms s k
sys = k*(s-1)*(s-2)/(s*(s+1));
sysEqn = 1+sys ==0;
routh_func = simplify(sysEqn)
I'm getting the output I want...
Routh Function
2 2
2 k + s - 3 k s + k s + s == 0
I want to the extract the coefficients [(1+k,1-3k,2k)] to be used with a Routh function. The problem I'm running in to is that the "== 0" needs to be removed and is stopping me from using something like this...
routh_coeffs = coeffs(routh_func)
syms epsilon
RA = routh(routh_coeffs,epsilon)
To discern the routh table. Yes I know routh isn't a built in function, credit to Author:Rivera-Santos, Edmundo J. E-mail:edmundo@alum.mit.edu. For the routh function (downloaded from these forums!).
Any help would be greatly appreciated. Thank you!

Accepted Answer

Star Strider
Star Strider on 22 Oct 2014
The Symbolic Math Toolbox assumes zero, so it’s not necessary to state it explicitly.
This will get you the coefficients:
syms s k
sys = k*(s-1)*(s-2)/(s*(s+1));
sysEqn = 1+sys;
[routh_func,den] = numden(sysEqn)
routh_coeffs = coeffs(routh_func, s)
  2 Comments
Star Strider
Star Strider on 22 Oct 2014
My pleasure!
I admire your courage in tackling classical control problems!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!