How can I incorporate the "s" symbolic variable in multiplication?
132 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(3 个)
bio lim
2016-12-3
编辑:bio lim
2016-12-3
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!