HW9 #3 - fprintf('RMSE for 2nd order equation:...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 %Engineering 6, Spring 2004, Problem 9.3 %Ryan Uy, 2509 %Section B05, Tues. 3-4 % set given (definite) velocities and corresponding distance v = [20 30 40 50 60 70] d = [45 80 130 175 255 340] % arrays first and second assigned first and second order polynomal fit % equations for points given first = polyfit(v,d,1) second = polyfit(v,d,2) % find difference of y values of first and second order polynomial equation % fits from given definite points yhat1 = polyval(first,v) yhat2 = polyval(second,v) % find error for each respective equation err1 = yhat1 - d err2 = yhat2 - d % find mean square error MSE1 = mean(err1.^2) MSE2 = mean(err2.^2) % find root mean square error RMSE1 = sqrt(MSE1) RMSE2 = sqrt(MSE2) % a) fprintf('First Degree polynomial fit coefficients: %.4f %.4f\n',first) fprintf('Second Degree polynomial fit coefficients: %.4f %.4f %.4f\n',second) % b) fprintf('RMSE for 1st order equation: %.1f\n',RMSE1)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: fprintf('RMSE for 2nd order equation: %.1f\n',RMSE2) % c) velocity = linspace(20,80,250) eval1 = polyval(first,velocity) eval2 = polyval(second,velocity) plot(v,d,'o',velocity,eval1,velocity,eval2),. .. % plot graphs legend('Raw data','Linear fit','Quadratic fit',4) % d) dist1 = polyval(first,75) dist2 = polyval(second,75) % print commands fprintf('Stopping distance according to 1st order polynomial fit: %.1f feet\n',dist1) Sheet1 Page 2 fprintf('Stopping distance according to 2nd order polynomial fit: %.1f feet\n',dist2) Sheet1 Page 3 % new velocity vector: 250 values from 20-80 % evaluate values for first order polynomial % evaluate values for second order polynomial %legend % evaluate velocity at 75 for first order equation % evaluate velocity at 75 for second order equation Sheet1 Page 4...
View Full Document

This note was uploaded on 01/22/2011 for the course ENG 006 taught by Professor Lagerstrom during the Spring '06 term at UC Davis.

Page1 / 4

HW9 #3 - fprintf('RMSE for 2nd order equation:...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online