Develop an m. file to compute velocity as a function of t. Then develop a script that uses this function to generate a plot of velocity versus time for t= -5 to 50. v(t)= 10t^2 -5t, 0<=t<=8 624-3t, 8<=t,+16 36t +12(t-16)^2, 16<=t<=26 2136e^(-0.1(t-26)), t>26 0, otherwise
Develop an m. file to compute velocity as a function of t. Then develop a script that uses this function to generate a plot of velocity versus time for t= -5 to 50.
v(t)= 10t^2 -5t, 0<=t<=8
624-3t, 8<=t,+16
36t +12(t-16)^2, 16<=t<=26
2136e^(-0.1(t-26)), t>26
0, otherwise

Code:
t=input('Enter time: ')
x=-5:50
if(t>=0 && t<=8)
velocity=10*t^2-5*t
f1=10*x.^2-5*x
plot(x,f1)
elseif(t>=8 && t<=16)
velocity=624-3*t
plot(x,624-3*x)
elseif(t>=16 && t<=26)
velocity=36*t+12*(t-16)^2
plot(x,36*x+12*(x-16).^2)
elseif(t>26)
velocity=2136*(exp^(-0.1*(t-26)))
plot(x,2136*(exp^(-0.1*(x-26))))
else
velocity=0
plot(x,0)
end
Step by step
Solved in 2 steps with 3 images









