Operate coefficients in Symbolic expressions
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I would like to know how to operate the coefficients in a symbolic expression.
Thanks!
Example:
syms s k kc
G_s=k/(s^3+6*s^2+10*s);
D_s=kc*(s+2)/(s+9.067);
t_s=(G_s*D_s)/(1+G_s*D_s);
vpa(simplify(t_s),5)
Result:

Desired result:

0 个评论
回答(1 个)
Ameer Hamza
2020-5-18
Maybe there is an easy option, but something like this will work
syms s k kc
G_s=k/(s^3+6*s^2+10*s);
D_s=kc*(s+2)/(s+9.067);
t_s=(G_s*D_s)/(1+G_s*D_s);
[n,d] = numden(t_s);
a = gcd(coeffs(n));
vpa(simplify((n/a)/(d/a)))
2 个评论
Walter Roberson
2020-5-18
There is no method implemented in MATLAB for this purpose. You are fighting against the internal rules for representation of ratios.
You could probably replace the last line with
vpa(n/a)/vpa(d/a)
另请参阅
类别
在 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!