MATLAB: Isolate a variable

functionsymbolicsyms

I can isolate one variable as an expression? example:
'x^2+2+x' em 'x = x^2 +2'
remembering that they are symbolic objects.
Thanks in advance.

Best Answer

If your input is x^2 + 2 + x then you cannot isolate x to one side of an equation, as your input is not an equation.
If your input is implicitly x^2 + 2 + x = 0 then your example output of x = x^2 + 2 is incorrect: instead x = -x^2 - 2
You cannot always isolate one variable -- not unless you are willing to make some restrictions on the form of the equation.
If you have a polynomial as input, then
S = x^2+2+x;
c = sym2poly(S);
isolated_x = x * c(end-1) - S;