MATLAB: How to convert y=f(x) to x=f(y)

functionMATLABpolynomial

I want to express s in terms of x
syms s;
a=1;
b=1.6;
x=(b+a)/2+(b-a)/2*s;
x=subs(x)
s=solve(x,s)

Best Answer

Try this:
syms s x
a=1;
b=1.6;
Eq = x == (b+a)/2+(b-a)/2*s;
s=solve(Eq,s)
producing:
s =
(10*x)/3 - 13/3
Without the numeric substitutions:
syms a b s x
Eq = x == (b+a)/2+(b-a)/2*s;
s=solve(Eq,s)
produces:
s =
(a + b - 2*x)/(a - b)
.
Related Question