Question

2. (20 pts) (Problem 2.18) Piecewise functions are sometimes useful when the relationship between adependent and an independent variable cannot be adequately represented by a single equation. Forexample, the velocity

of a rocket might be described by: v(t)=\left\{\begin{array}{cc} 11 t^{2}-5 t & 0 \leq t \leq 10 \\ 1100-5 t & 10 \leq t \leq 20 \\ 50 t+2(t-20)^{2} & 20 \leq t \leq 30 \\ 1520 e^{-0.2(t-30)} & t>30 \\ 0 & \text { otherwise } \end{array}\right. Develop a well-structured function in MATLAB to compute v as a function of t. Then use this function to generate a table of v versus t for t = -5 to 50 at increments of 0.5 and plot a curve of v versus t with clearly labelled axis and legend. Turn in the source code as well as the results.

Fig: 1

Fig: 2

Fig: 3