I was initially having trouble with my function, but now since that is running okay, my script is not. It involves a for loop and I'm not sure what I'm doing wrong.
Here is my function file:
function v = piecewise_fun(t)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));endend
And here is what I have for my script file:
t = -5:50hold onfor i =-5:t % I'm not sure if this is even right!?
v = piecewise_fun(t);endplot(v,t)
So, I get the following error:
Undefined function or variable 'v'. Error in piecewise_plot (line 6) plot(v,t)
Best Answer