How can I incorporate the "s" symbolic variable in multiplication?
64 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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!
0 Kommentare
Antworten (3)
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)
0 Kommentare
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.
0 Kommentare
Siehe auch
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!