The height of a rocket (in meters) can be represented by the following equation:
ID: 3734627 • Letter: T
Question
The height of a rocket (in meters) can be represented by the following equation:
Height = 2.13 t^2 0.0013 t^4 + 0.000034tT^4.751
Create a vector of time (t) values from 0 to 100 at 2-second intervals.
a) Use the find function to determine when the rocket hits the ground. (Hint: The value
of height will be positive for all values until the rocket hits the ground.)
b) Use the max function to determine the maximum height of the rocket and the
corresponding time.
c) Create a plot with t on the horizontal axis and height on the vertical axis until the
rocket hits the ground. Be sure to add a title and axis labels. *
d) Display the maximum height part(b), on the plot by creating the input for the textbox
controlled by sprintf command. It should appear like this “the maximum height is …”
Explanation / Answer
Part a)
Matlab script to determine the when the rocket will hit the ground
t =0:2:100;
h = (2.13*(t.^2)) - (0.0013*(t.^4)) + (0.000034*(t.^4.751));
time = find(h>0);
x_ans = max(time);
t_ans = t(x_ans)
Matlab scripts output shows
ie rocket will hit the ground at 62 secs
Part b)
To determine the maximum height of rocket we have to use max function of height vector as follows
h_ans = max(h(time))
The output for this part shows
Part c)
To plot the path we have to use following code
plot(t(time),h(time)), xlabel('Time Secs'), ylabel('Height Meter'), title('Profile of Rocket'), grid on
Part d)
To Display the maximum height we have to use follwing code
dim = [.3 .68 .3 .2];
format_str = 'The maximum height is %d';
annotation('textbox',dim,'String',sprintf(format_str,h_ans))
So the complete code is as below
t =0:2:100;
h = (2.13*(t.^2)) - (0.0013*(t.^4)) + (0.000034*(t.^4.751));
time = find(h>0);
x_ans = max(time);
t_ans = t(x_ans)
h_ans = max(h(time))
plot(t(time),h(time)), xlabel('Time Secs'), ylabel('Height Meter'), title('Profile of Rocket'), grid on
dim = [.3 .68 .5 .2];
format_str = 'The maximum height is %d';
annotation('textbox',dim,'String',sprintf(format_str,h_ans))
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.