%% Homework for 6.6 and Line of Best Fit % NOTE: This will not run until you fill in some missing commands %% Data Set 1: Hanford Data % Download the data set HanfordData1.mat from the class website load HanfordData1 % We have 9 data points- Index (the indep variable) and Deaths (dependent) x=Index; y=Deaths; A=[x(:), ones(9,1)]; % Find the slope and intercept, and label then as m, b % Plotting routine (using the m, b found previously) figure(1) xx=linspace(min(x),max(x),200); yy= m*xx + b; plot(x,y,'b^',xx,yy,'k-'); %See the help file for plot to see what this means %% Data Set 2: Knee Girth to Height % Download the data set Body1.mat from the class website clear; %Clear the old variables out load Body1 % Some plotting commands to see the data first: figure(2) plot(KneeGirth,Height,'.') plot(KneeGirth(menidx),Height(menidx),'r.',KneeGirth(womenidx),Height(womenidx),'b.'); legend('Men','Women') x=KneeGirth; y=Height; A=[KneeGirth,ones(size(KneeGirth))]; % Get the slope and intercept, and label them as m, b % Once m, b are found, you can run this code: xx=linspace(min(x),max(x),200); yy= m*xx + b; figure(3); %Opens a new figure for the new plot plot(x,y,'b.',xx,yy,'k-');