EGR_102_Lab_05A_Solution

EGR_102_Lab_05A_Solution - plot(x_plot,y_plot) title(...

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

View Full Document Right Arrow Icon
Lab 05A Homework Name: Solution Section # Spring 2012 The script was saved as tensile_strength.m % Script 'tensile_strength.m' % Name, Section # % This script calculates the least-squares linear fit of a set of tensile % strength and time data supplied. It also plots the linear fit over a % 3-hour heating period. % Step 1 x = 10:20:110 % min y = [15.8 48.4 81.2 147.5 186.8 204] % MPa % Step 2 x_summed = sum(x); y_summed = sum(y); xsq_summed = sum(x.^2); xy_summed = sum(x.*y); % Step 3 n = length(x); a1 = (n*xy_summed - x_summed*y_summed)/(n*xsq_summed - x_summed^2) % Step 4 x_ave = mean(x); y_ave = mean(y); a0 = y_ave - a1*x_ave % Step 5 x_plot = 0:30:180; y_plot = a1*x_plot + a0;
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
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: plot(x_plot,y_plot) title( 'Linear Fit Line of Heat Treated Metal Composite' ) xlabel( 'Time heat treated (min)' ) ylabel( 'Tensile strength (MPa)' ) grid on % Extra hold on plot(x,y, 'rs' ) % adding the original data points to the plot hold off Command Window Output >> run tensile_strength x = 10 30 50 70 90 110 y = 15.8 48.4 81.2 147.5 186.8 204 a1 = 2.0321 a0 = -7.9786 According to the linear fit line, the tensile strength after 180 minutes should be approximately 358 MPa 20 40 60 80 100 120 140 160 180-50 50 100 150 200 250 300 350 400 Linear Fit Line of Heat Treated Metal Composite Time heat treated (min) Tensile strength (MPa)...
View Full Document

This note was uploaded on 04/02/2012 for the course EGR 100 taught by Professor Hinds during the Fall '08 term at Michigan State University.

Page1 / 2

EGR_102_Lab_05A_Solution - plot(x_plot,y_plot) title(...

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

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