In MATLAB: 1. The height of an object is defined by the following equation: h =
ID: 1996741 • Letter: I
Question
In MATLAB:
1. The height of an object is defined by the following equation: h = int_h - t - 5*sin(t) Where “h” is the current height, "int_h" is the initial height, and “t” is current time. Write a program using the WHILE LOOP that will ask for a given initial height (int_h) and return the time that the object is at or just above zero, using a time step of 0.001. Test your program for int_h at 8, 15, and 20. Print the solutions to all three heights in the format below: “The time for the object to reach a height of [Insert Height] is [Insert Time] seconds.”
Explanation / Answer
int_h = input('Enter the initial height:');
h = int_h;
t = 0;
while h>0
h_temp = h;
t_temp = t;
t = t+0.001;
h = int_h - t - 5*sin(t);
end
fprintf('The time for the object to reach a height of %f is %f seconds',h_temp,t_temp);
OUTPUT:
Enter the initial height:8
The time for the object to reach a height of 0.003919 is 6.572000 seconds
Enter the initial height:15
The time for the object to reach a height of 0.004746 is 12.981000 seconds
Enter the initial height:20
The time for the object to reach a height of 0.001708 is 19.042000 seconds
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.