Piecewise functions - File Exchange - MATLAB Central
https://www.mathworks.com/matlabcentral/fileexchange/939410.04.2006 · Would you like to be able to specify a piecewise function? For example, piecewise_eval can do this: x < -5, y = 2 -5 <= x < 0, y = sin(x) 0 <= x < 2, y = x.^2 2 <= x < 3, y = 6 3 <= x, y = inf y = piecewise_eval(-10:10,[-5 0 2 3], ... {2,'sin(x)','x.^2',6,inf}) Plot a …