2. There is an Excel file named rocketstagedata.xls. a. Write a MATLAB program t
ID: 3632737 • Letter: 2
Question
2. There is an Excel file named rocketstagedata.xls.a. Write a MATLAB program to read the data (numeric and text) from the excel spreadsheet.
? The columns of text represent the stages of the rocket.
? The first column of numbers represents time in seconds.
? The second column of numbers represents the altitude in meters.
b. (5 points) Using the same MATLAB program,
i. Create a variable t with the time data and a variable h for the altitude data.
ii. Find the best-fit cubic curve (3rd order polynomial) for the above data.
iii. Plot the raw data: time t on the x-axis and altitude h on the y-axis using ‘o’ markers.
iv. On the same graph, plot the best-fit cubic curve using a solid red line.
v. Include grid lines on your graph.
vi. Include relevant labels with units on the graph.
vii. Include a clearly labeled legend on the graph.
Explanation / Answer
x = xlsread('rocketstagedata.xls'); t = x(:,1); h = x(:,2); k = polyfit(t,h,3); for i = numel(t) h_bestfit(i) = k(1)*t(i)^3+k(2)*k(2)*t(i)^2+k(3)*t(i)+k(4); end plot(t,h,'o',t,h_best_fit,'r-'); grid on; xlabel('Time (s)'); ylabel('Altitude (meters)'); legend('Actual Data','Best Fit');
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.