MATLAB: Could someone check the work

functionpiecewise

I've created a function that will calculate a piecewise function to be called on. I want to make sure that it is okay.
Here is my code:
function v = vfun(t)
t = -5:50;
if 0 > t & t > 8
v = (10.*t)^2 - (5.*t);
elseif 8 <= t & t <= 16
v = 624 - 5.*t;
elseif 16 <= t & t <= 26
v = 36.*t + 12.*(t-16).^2;
elseif t > 26
v = 2136*exp(-0.1.*(t-26));
end
I am also going to be creating a script that will plot v vs t for t = -5 to 50. I'm not too sure that I should have included that above.
Thanks!

Best Answer

if 0 > t & t > 8 is always false
Related Question