Hi, I have a function with a set of equations which needs to be solved for unknowns x. However, this function consists of piecewise function of matlab. The code looks something like
function dx = myFunction(x) a1 = x(1); a2 = x(2); c = piecewise(a2>0,a1^2,0) dx(1) = a1*a2 + a2*c + a1*c; dx(2) = a2*c;end
When I try to use fsolve on this function, MATLAB gives an error message saying the following: Undefined function 'piecewise' for input arguments of type 'logical'
I was wondering if there is a way I can make MATLAB evaluate the piecewise expression for each iteration of fsolve.
Thanks, Rupa
Best Answer