Problem14_7 - %9.8fc\n\n',a(1),a(2),a(3),a(4),a(5));

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

View Full Document Right Arrow Icon
function Problem14_7(T,o1,o2,o3,ti,oi,ci) %Problem 14.7 % %T=temperature in degrees Celsius %ci=given concentration along with ti=given temp, from these values, calc %dissolved oxygen and percent error. True value of dissolved oxygen is %passed into funciton by oi. % TT=[T;T;T]; e=[zeros(7,1); linspace(10,10,7)'; linspace(20,20,7)']; d=size(TT); Z=[ones(d) TT TT.^2 TT.^3 e]; oxg=[o1;o2;o3]; a=Z\oxg; fprintf('\n0= %8.6f + %8.7fT + %9.8fT^2 + %11.10fT^3 +
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: %9.8fc\n\n',a(1),a(2),a(3),a(4),a(5)); y2=a(1)+a(2)*ti+a(3)*ti^2+a(4)*ti^3+a(5)*ci; fprintf('\nAt T=%2d and c=%2d, the predicted value of o is %9.8f which is much closer to the true\nvalue of %3.2f than in the previous problem\n\n',ti,ci,y2,oi); a0=a(1); a1=a(2); a2=a(3); a3=a(4); a4=a(5); ofit=a0+a1.*TT+a2.*TT.^2+a3.*TT.^3+a4.*e; %linear regression n=size(ofit); A=[ones(n) oxg]; reg=A\ofit; o2=linspace(min(oxg),max(oxg),2); rfit=reg(1)+reg(2)*o2; plot(oxg,ofit,'o',o2,rfit);...
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