Operate coefficients in Symbolic expressions

조회 수: 1 (최근 30일)
Ignacio Fidalgo
Ignacio Fidalgo 2020년 5월 18일
댓글: Walter Roberson 2020년 5월 18일
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:

답변 (1개)

Ameer Hamza
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
Ignacio Fidalgo
Ignacio Fidalgo 2020년 5월 18일
Thank you very much for your answer, but as you've said, i'm looking for an easier option. Maybe one already implemented in matlab, since this is a very simple example but it can get harder.
Walter Roberson
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 CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by