multiple_linear_regression

# multiple_linear_regression - P=Z\oxy; fprintf('\no = %10.8f...

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

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 into funciton by tv. % %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)']; Z=[ones(size(Ttotal)) Ttotal c];

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: P=Z\oxy; fprintf('\no = %10.8f + %9.8fT + %9.8fc\n\n',P(1),P(2),P(3)); %--------------------------------------------------------------------------y=P(1)+P(2).*Ttotal+P(3).*c; n=size(y); A=[ones(n) oxy]; reg=A\y; o2=linspace(min(oxy),max(oxy),2); rfit=reg(1)+reg(2)*o2; plot(oxy,y,'o',o2,rfit); title('Polynomial regression'); %percent relative error y=P(1)+P(2)*tg+P(3)*cg; perr=abs((y-tv)/y)*100; fprintf('At T=%2d and c=%2dC, the predicted value of o is %8.7f\nPercent relative error=%5.4fpercent\n\n',tg,cg,y,perr);...
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.

### Page1 / 2

multiple_linear_regression - P=Z\oxy; fprintf('\no = %10.8f...

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

View Full Document
Ask a homework question - tutors are online