Find degree of non-polynomial expression in Matlab

8 ビュー (過去 30 日間)
Arvind Rajan
Arvind Rajan 2014 年 7 月 15 日
回答済み: Christopher Creutzig 2014 年 8 月 29 日
Hi,
say i have an expression as such:
syms x
y = x^(-5/2)
how to find the exponent of x since y is not a polynomial. is it possible?
thanks

回答 (2 件)

Star Strider
Star Strider 2014 年 7 月 15 日
Unfortunately not.
In theory,
xpnt = log(y)/log(x)
should work because it’s a fundamental log identity for conversion between log bases. The Symbolic Math Toolbox simply returns the symbolic expression, not the exponent.
Maybe in a future release...

Christopher Creutzig
Christopher Creutzig 2014 年 8 月 29 日
That depends on what exactly you are looking for in the general case. Here's something that works in this particular one:
>> simplify(log(y)/log(x),'IgnoreAnalyticConstraints',true)
ans =
-5/2
(The result is valid in general, but simplification succeeds along a way that ignores branch cuts and is not universally valid.)
If your expression gets more complicated, you may need to use MuPAD functions directly:
>> feval(symengine,'ldegree',feval(symengine,'series',y,x))
ans =
-5/2
(If you want to look at the output of the feval(symengine,'series',y,x) part, I heartily recommend the pretty function.

カテゴリ

Help Center および File ExchangeAssumptions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by