How to work with piecewise results that are returned by the solve() function
Show older comments
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]}])
Accepted Answer
More Answers (1)
Walter Roberson
on 10 Jul 2017
0 votes
However, in your R2010a version, you need to use evalin(symengine) or feval(symengine) to execute 'op' operations to pull part the expression.
1 Comment
Trevor Gates
on 11 Jul 2017
Categories
Find more on Properties and Assumptions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!