SAE70 - %calculates cod n=numel(T); maxs=max(T); xold=0;...

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

View Full Document Right Arrow Icon
function SAE70(T,V) %Problem 13.18 % %T=Temperature in degrees celsius %Viscosity,u,N*s/m^2 % %This Program uses linear regression to find the equation of the line %that best fits the data and the r^2 value. x=log10(T); a=log10(V); n=length(T); c=ones(n,1); CM=[c x]; %Coeff Matrix ans=CM\a; aa=10^(ans(1)); ab=ans(2); fprintf('\na=%5.4f, b=%5.4f\n\n',aa,ans(2)); %Need a better fit for this graph %need more points--> TT=linspace(min(T),max(T),100); y=aa.*TT.^ab; plot(T,V,'k o',TT,y,'g'); title('Plot of original data with nonlinear model fit:'); ylabel('T(C)'); xlabel('Viscosity(N*s/m^2)'); %-------------------------------------------------------------
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: %calculates cod n=numel(T); maxs=max(T); xold=0; yold=0; xi2old=0; yixi_old=0; srold=0; St_old=0; ysum=sum(V)/n; xsum=sum(T)/n; for i=1:n xnew=T(i); xi=xnew+xold; xold=xi; ynew=V(i); yi=ynew+yold; yold=yi; yixi=T(i)*V(i); yixi=yixi+yixi_old; yixi_old=yixi; xi2=T(i)^2; xi2=xi2+xi2old; xi2old=xi2; St=(V(i)-ysum)^2+St_old; St_old=St; end a1=(n*yixi-xi*yi)/(n*xi2-xi^2); ao=ysum-a1*xsum; for i=1:n yi=V(i); xi=T(i); Sr=(yi-ao-a1*xi)^2; Sr=Sr+srold; srold=Sr; end %correlation coefficient r=(St-Sr)/St...
View Full Document

Page1 / 2

SAE70 - %calculates cod n=numel(T); maxs=max(T); xold=0;...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online