How can I incorporate the "s" symbolic variable in multiplication?

122 Ansichten (letzte 30 Tage)
Brian Kalinowski
Brian Kalinowski am 3 Dez. 2016
Bearbeitet: Walter Roberson am 21 Dez. 2021
Okay so this is a simple code for a simple closed loop control system:
sys=tf(1,[1 2 2]);
syms s
ctr=4+(3/s);
e_cl=feedback(1,sys*ctr);
u_cl=feedback(ctr,sys);
y_cl=feedback(sys*ctr,1);
step(e_cl,'b',u_cl, 'r',y_cl, 'g')
[num,den]=tfdata(y_cl,'v');
roots(den);
stepinfo(y_cl);
When I run it, it gives me an error for the e_cl equation saying: "Invalid operand. Variables of type "sym" cannot be combined with other models."
This makes sense to me, since "s" is symbolic you cannot multiply numbers. Any idea how I can make this work? s is the laplace variable so making it a vector wouldn't work with finding the step responses. I need to somehow make "ctr=4+3/s" into a function where I can multiply it by sys. Thanks!

Antworten (3)

Andrei Bobrov
Andrei Bobrov am 4 Dez. 2016
sys=tf(1,[1 2 2]);
s = tf('s');
ctr=4+(3/s);
e_cl=feedback(1,sys*ctr)

bio lim
bio lim am 3 Dez. 2016
Bearbeitet: bio lim am 3 Dez. 2016
Defining a symbolic variable s is different than the s = jw in your transfer function. I believe, if you write a transfer function with syms s, MATLAB doesn't assume it's a transfer function.
Now you might ask, since the transfer function is a ratio of the input and the output, why it shouldn't work? the built-in function tf contains more information that can be used in different control system commands in MATLAB. It has other properties associated with it, not only just the ratio.
To solve your problem, simply write the transfer function of your controller as:
ctr = tf([4 3], [1 0]);
and it should give you your results.

Walter Roberson
Walter Roberson am 4 Dez. 2016
Bearbeitet: Walter Roberson am 21 Dez. 2021

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by