MATLAB: How to expose a symbol from an equation? I have Symbolic Math Toolbox, if it is necessary mathematicsMATLABsymbolicSymbolic Math Toolbox Let say I have an equation like: y = @(x) x^2 + 2; I want to express X in dependence of Y like: x = @(y) sqrt(y-2); Best Answer You have to set a few rules for the Symbolic Math Toolbox, but this is one possibility:syms x y positiveassume(y > 2)Eqn = y == x^2 + 2;x = solve(Eqn)x =(y - 2)^(1/2)EDIT — If you want to create an anonymous function from ‘x’, use the matlabFunction function. Related SolutionsMATLAB: Solving simultaneous equations without martix method You would most likely have to use the Symbolic Math Toolbox:syms x y Eq1 = x + y == 10;Eq2 = x + 2*y == 15;[x,y] = solve(Eq1, Eq2)x =5y =5 MATLAB: Solving two symbolic equations simultaneously syms x y a beq1=a==x+y;eq2=b==x-y;[xsol,ysol]=solve([eq1 eq2],[x y])sol.xsol.yor:syms x y a beq1=a==x+y;eq2=b==x-y;[xsol,ysol]=solve([eq1 eq2],[x y]) Related QuestionDisplay necessary function argumentsHow to plot a sym function with constant function such as x=2(vertical line) & y=3(horizontal line)Substiton of a variable in a equationFileExchange: Zip, Toolbox, App
Best Answer