MATLAB: How to isolate y from f(x) = g(x, y) piecewise equation or function

equationisolatepiecewiserearrange

I made an equation of x and y, by using piecewise function like below matlab code,
and to rearrange the equation about y, i used 'isolate' command, but the result is only y == 3 (defined in interval [5, 10]).
What should i do to get the result like "ans = y == piecewise(x<5, 2*x – x^2, x in Dom::Interval([5], 10), 3, 10 <= x, x^3 – x^2)"

Best Answer

First, please copy your code from the Editor and paste it here, then use the Code button to format it. (My version of MATLAB cannot run images of code.)
Second, isolate has its uses, however if you want an expression for ‘y’, use the solve function:
syms f(x) g(x) h(x) y
f = 2*x;
g = 3+x^2;
h = x^3;
i(x) = piecewise(0 <= x < 5, f, 5 <= x < 10, g, 10 <= x < 20, h);
eqn = i == x^2 + y;
y_s = solve(eqn, y);
producing:
y_s =
3
- x^2 + 2*x
x^3 - x^2
Note the conditions for those solutions in the Warning that appears:
Warning: Solutions are valid under the following conditions: x < 10 & 5 <= x;
x < 5 & 0 <= x;
x < 20 & 10 <= x. To include parameters and conditions in the solution, specify the
'ReturnConditions' value as 'true'.
Related Question