multiple_linear_regression - Z=[ones(size(Ttotal)) Ttotal...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function multiple_linear_regression(T,o1,o2,o3,cg,tg,tv) %Problem 14.6 % %T=temperature in degrees Celsius %cg=given concentration along with tg=given temp, from these values, calc %dissolved oxygen and percent error. True value of dissolved oxygen is %passed inot % %p=polyfit(x,y,n) % x=independent variable % y=dependent variable % n=the order of the polynomial Ttotal=[T; T; T]; oxy=[o1; o2; o3]; c=[zeros(7,1); linspace(10,10,7)' ;linspace(20,20,7)'];
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Z=[ones(size(Ttotal)) Ttotal c]; b=oxy-c; P=Z\b; fprintf('\no = %10.8f + %9.8fT + %9.8fc\n\n',P(1),P(2),P(3)); %--------------------------------------------------------------------------%need help graphing TT=linspace(min(Ttotal),max(Ttotal),2); y=P(1)+P(2).*T+P(3)+P(3)*15; plot(T,o2,'o',T,o3,'o',T,y); title('Polynomial regression'); xlabel('T(C)'); ylabel('Oxygen(mg/L)'); %percent relative error y=P(1)+P(2)*tg+P(3)+P(3)*cg; y= fprintf('At T=12 and c=15, the predicted value of o is 9.53335714...
View Full Document

This note was uploaded on 09/27/2011 for the course EGM 3344 taught by Professor Raphaelhaftka during the Spring '09 term at University of Florida.

Ask a homework question - tutors are online