Home /
Expert Answers /
Computer Science /
matlab-3-sometimes-we-use-piecewise-functions-when-the-relationship-between-a-dependent-and-an-ind-pa881
(Solved): MATLAB
3. Sometimes we use piecewise functions when the relationship between a dependent and an ind ...
MATLAB
3. Sometimes we use piecewise functions when the relationship between a dependent and an independent variable can not be represented by a single equation. Here, we describe the velocity of a rocket with time using a piecewise function \[ v(t)=\left\{\begin{array}{ll} 11 t^{2}-5 t & 0 \leq t \leq 10 \\ 1100-5 t & 1030 \\ 0 & \text { otherwise } \end{array}\right. \] Develop an M-file function to compute \( v \) as a function of \( t \). Then, use this function to generate a plot of \( v \) versus \( t \) when \( t \) changes from \( -8 \) to 80 . Use a step size of \( 0.4 \) for \( t \), and label the axes in the plot. Also, use the scatter command to plot the maximum velocity on the same plot. Annotate the plot with a legend. This should all be done in the code. (See help xlabel and help ylabel, e.g., if you are not familiar with these commands).
The following is a screenshot of the code to find the rocket velocity at a given point in time using the piecewise function definition as given in the question. We use the && operator to chain conditions together. Further, we use the formulae given