Factor symbolic expression involving exp()

조회 수: 2 (최근 30일)
Philip
Philip 2015년 9월 13일
댓글: Philip 2015년 9월 13일
I have a symbolic function exp(a+b), and would like to factor out A=exp(a) to produce exp(a+b) = A*exp(b), but I cannot figure out how to do this in MATLAB. Below is my attempt:
syms a b A
X = exp(a+b)
Y = subs(X,exp(a),A) % = A*exp(b)
however, Y = exp(a+b). For some reason, MATLAB cannot determine exp(a+b) = exp(a)*exp(b) = A*exp(b).
Any help is greatly appreciated.

채택된 답변

Walter Roberson
Walter Roberson 2015년 9월 13일
subs() replaces one sub-expression tree with a different sub-expression tree. exp(a) is not present as a sub-expression in exp(a+b) so you cannot use subs() to make that replacement in it.
What might work is
Y = subs(expand(X), exp(a), A);
  댓글 수: 3
Walter Roberson
Walter Roberson 2015년 9월 13일
Try
Y = expand(subs(X, a, ln(A)))
Philip
Philip 2015년 9월 13일
That's perfect! Thanks again.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numeric Solvers에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by