hw8_solution - , 'NorthWest' ) % Evaluate the polynomials...

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

View Full Document Right Arrow Icon
1. Plot the given data and best-fit curves. Estimate the stopping distance for a car traveling at 65 mph. Below is my code and output. Code: % ASE 311, HW 8, part 1. % Date: 28 Oct 09. clear all close all clc %% speed = [30 45 60 75 90 120]'; think = [5.6 8.5 11.1 14.5 16.7 22.4]'; brake = [5.0 12.3 21.0 32.9 47.6 84.7]'; % Plot the given data. figure(1) plot(speed,think, '-*' ,speed,brake, '-*' ) xlabel( 'Speed (km/hr)' ),ylabel( 'Distance to think or brake (m)' ) title( 'Stopping Distance at Various Speeds' ) grid on hold on % Create best-fit polynomials to estimate the plotted data. f1 = polyfit(speed,think,1); %guess first order f2 = polyfit(speed,brake,2); %guess second order % Evaluate the polynomials for plotting. x = speed(1):.1:speed(end); think_poly = polyval(f1,x); brake_poly = polyval(f2,x); % Plot the best-fit curves with the data. figure(1) plot(x,think_poly, 'k' ,x,brake_poly, 'r' ) legend( 'Thinking' , 'Braking' , 'Think poly' , 'Brake poly' , 'Location'
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
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: , 'NorthWest' ) % Evaluate the polynomials for a car going 65 mph. v = 65*1.6; %car's speed in km/hr dist = (polyval(f1,v) + polyval(f2,v))*3.281; %stopping dist in ft fprintf( 'The stopping distance for a car going 65 mph is %4.1f feet.\n' ,dist) 1. Output: The stopping distance for a car going 65 mph is 272.5 feet. Notes: – To “develop” the best-fit equations, i.e., to figure out the order of the best-fit polynomial, you must plot the data points, and notice that the thinking data appears to be linear, and the braking data appears to be quadratic. Polynomials of order 1, 2, 3, or 4 are acceptable to fit to the thinking data, and polynomials of order 2, 3, 4, or 5 are acceptable to fit to the braking data. I used 1st-order and 2nd-order, respectively. – Convert 65 mph to km/hr. The number you get as an output will be in meters, so convert that number to feet....
View Full Document

This note was uploaded on 01/20/2010 for the course ASE 311 taught by Professor Kraczek during the Spring '08 term at University of Texas.

Page1 / 3

hw8_solution - , 'NorthWest' ) % Evaluate the polynomials...

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

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