MATLAB: Clarification for solve function

MATLABsolve

This is the code I have written:
x = 0:1:15;
U = 2*x+5;
L = 3*x-10;
u = 2*(x-1)+5;
l = 3*(x-1)-10;
U_plus = 2*(x+1)+5;
L_plus = 3*(x+1)-10;
c = abs(U_plus – L_plus);
C = abs(U-L);
C_plus = abs(u-l);
s1 = solve(abs(U_plus-L_plus)==0,x);
s2 = solve(abs(U-L)==0,x);
s3 = solve(abs(u-l)==0,x);
This is the error I am facing:
Error using sym.getEqnsVars>checkVariables (line 87)
Second argument must be a vector of symbolic variables.
Error in sym.getEqnsVars (line 54)
checkVariables(vars);
Error in solve>getEqns (line 429)
[eqns, vars] = sym.getEqnsVars(argv{:});
Error in solve (line 226)
[eqns,vars,options] = getEqns(varargin{:});
Error in Final (line 21)
s1 = solve(abs(U_plus-L_plus)==0,x);
Am unable to debug this. Any help is highly appreciated

Best Answer

syms x;
U = 2*x+5;
L = 3*x-10;
u = 2*(x-1)+5;
l = 3*(x-1)-10;
U_plus = 2*(x+1)+5;
L_plus = 3*(x+1)-10;
c = abs(U_plus - L_plus);
C = abs(U-L);
C_plus = abs(u-l);
s1 = solve(abs(U_plus-L_plus)==0,x)
s2 = solve(abs(U-L)==0,x)
s3 = solve(abs(u-l)==0,x)
Related Question