MATLAB: Solving Equation

MATLABnumeric equation solving

I'm trying to solve a equation, and I'm having some issues…
syms Xell Xelr Xerl Xerr s q; s = solve('(Xell-Xelr)/(Xerl-Xerr) = -(((s-1)*(s-(1+2/q)))/((s+1)*(s+(1+2/q))))', s);
How do i use the results and enter values in for the syms (i.e. Xell Xelr Xerl Xerr q) to solve for s?
Thanks! Mark

Best Answer

Not sure the best method, convert to function handles:
syms Xell Xelr Xerl Xerr s q;
s = solve('(Xell-Xelr)/(Xerl-Xerr) = -(((s-1)*(s-(1+2/q)))/((s+1)*(s+(1+2/q))))', s)
s1 = str2func(['@(Xell, Xelr, Xerl, Xerr, q)' char(s(1))]);
s2 = str2func(['@(Xell, Xelr, Xerl, Xerr, q)' char(s(2))]);
% Evaluate at the desired values
s1(1,1,3,1,2)
s2(1,1,4,1,2)
Oleg