MATLAB: How to solve a system of equations in matlab equations hello, How do I solve this system of equations in matlab for F(-2:2) ? f(x)= x+2 if x<=0 -x+2 if x>0 Apparently you can't use an if for this solution, but I don't really understand why either. Thanks in advance Best Answer Try thisf = @(x) (x+2).*(x<=0) + (-x+2).*(x>0);(x<=0) returns 1's where it's true and 0 where it's false. Similarly for (x>0) Related SolutionsMATLAB: How could I make a periodic function in MatLab f = @(t) 2 * mod(t, 5);fplot(f, [-10 10]) MATLAB: Differentiation solve(diff(x^2)) Related Question6 Simultaneous equations with 6 UnknownsSolve 12 equations with 12 unknown ERROR: FSOLVE requires all values returned by functions to be of data type double.How to draw the graph of a function that has different structure in its different domain
Best Answer