This preview shows page 1. Sign up to view the full content.
Unformatted text preview: % --- CALCULATIONS ---P1 = polyfit(year,telcost,1) % linear regression coefficients P telcost_fit = polyval(P1,year) % predicted expenditures ($) from the % linear regression telcost_mean = mean(telcost) % mean value of telephone expenditures ($) t % SSE computation SSE = sum((telcost-telcost_fit).^2) % SST computation SST = sum((telcost-telcost_mean).^2) % r-squared value r_sq = 1-SSE/SST r % --- OUTPUTS ----plot(year,telcost,'rs') hold on plot(year,telcost_fit,'k-') xlabel('year') ylabel('cost ($)') title('Telephone expenditures') legend('raw data','best fit','Location','SouthEast') l fprintf('Eqn of best fit is: \n') fprintf('y = %4.1fx + (%4.0f) \n',P1(1),P1(2)) fprintf('r_squared = %4.3f \n',r_sq) f % Eqn of best fit is: % y = 27.5x + (-54087) % r_squared = 0.992...
View Full Document
This note was uploaded on 08/25/2011 for the course ENGR 195 taught by Professor Staff during the Fall '08 term at Purdue University-West Lafayette.
- Fall '08