フィルターのクリア

How to work with piecewise results that are returned by the solve() function

1 回表示 (過去 30 日間)
Trevor Gates
Trevor Gates 2017 年 7 月 9 日
コメント済み: Trevor Gates 2017 年 7 月 11 日
Hello,
I have the Student version of Matlab, version R2010a. When I use the solve() function, it sometimes returns a piecewise result, as in the example below. My question is how to parse out the details of that piecewise sym object (i.e. obtain the various parts and assign them to variables). In case it helps, I am not using the solve() function directly, but rather, I am using it via symengine, i.e.
Sol = evalin(symengine,'solve(...)');
Sol = piecewise([s < 1/2, {[a = s, lambda1 = 0, lambda2 = 4 - 8*s]}], [1/2 <= s, {[a = 1/2, lambda1 = 0, lambda2 = 0]}])

採用された回答

Karan Gill
Karan Gill 2017 年 7 月 10 日
Honestly, the simplest solution is to upgrade to at least R2016b where "piecewise" was introduced in Symbolic Math Toolbox. Otherwise, you can use "MuPAD" directly for these calculations, because working through "evalin" or "feval" is messy.

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 7 月 10 日
In R2012a children() was introduced which can help with this kind of analysis.
However, in your R2010a version, you need to use evalin(symengine) or feval(symengine) to execute 'op' operations to pull part the expression.

カテゴリ

Help Center および File ExchangeProperties and Assumptions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by