0% found this document useful (0 votes)
21 views

Rectilinear y MX+C Log-Log y B X M. Semilog y B (10) MX

The document discusses different types of note formulas including rectilinear, log-log, and semilog. It then shows examples of using polyfit and polynomial regression to fit lines to datasets with different variable types and orders of polynomials. Residuals and goodness of fit are also calculated for some of the examples.

Uploaded by

Rafat Safayet
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Rectilinear y MX+C Log-Log y B X M. Semilog y B (10) MX

The document discusses different types of note formulas including rectilinear, log-log, and semilog. It then shows examples of using polyfit and polynomial regression to fit lines to datasets with different variable types and orders of polynomials. Residuals and goodness of fit are also calculated for some of the examples.

Uploaded by

Rafat Safayet
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Note Formula

rectilinear= y=mx+c

log-log = y = b*x^m.

semilog=y=b(10)mx

x = 25:5:45;

y = [5, 260, 480, 745, 1100];

p = polyfit(x,y,1) ;

xp= 0:1:45;

yp=53.5*xp - 1354.5 ;

plot(x,y,'o', xp,yp)
yp=p(1)*xp + p(2)

x = [2.5:0.5:6,7:10];

y = [1500,1220,1050,915,810,745,690,620,520,480,410,390];

p = polyfit(log10(x),log10(y),1);

m = p(1) ;

b = 10^p(2) ;

xp= 1:.01:100;

yp= b*xp.^m;

loglog(x,y,'o', xp,yp)

time = 0:0.1:0.6;

temp = [300,150,75,35,12,5,2];

p = polyfit(time,log10(temp),1); m = p(1)

b = 10^p(2)
time = 0:0.1:0.6;

temp = [300,150,75,35,12,5,2];

p = polyfit(time,log10(temp),1);

m = p(1)

b = 10^p(2)

time = 0:0.5:4;

voltage = [100,62,38,21,13,7,4,2,3];

p = polyfit(time,log10(voltage),1);

m = p(1);

b = 10^p(2) ;

time_p= 0:0.01:5;

voltage_p= b*10.^(m*time_p);

semilogy(time,voltage,'o', time_p,voltage_p);

x = 550:50:750;

y =[41.2,18.62,8.62,3.92,1.86];

p = polyfit(x,log10(y),1);

m = p(1) ;

b = 10^p(2) ;

xp= 500:10:800;

yp= b*10.^(m*xp);

semilogy(x,y,'o', xp,yp) ;
Farhan GA

5:15 PM

x = 20:10:70;

y = [45,80,130,185,250,330];

xp = 20:0.01:70;

p = polyfit(x,y,2) ;

yp = polyval(p,xp);

J = sum((polyval(polyfit(x,y,2),x)-y).^2);

plot(xp,yp,x,y,'o'),axis([20 70 0 350]),ylabel('d (ft)'),xlabel('v (mph)')

mu = mean(y);

S = sum((y-mu).^2); r2 = 1-J/S;

r2

d1 = [1,2,3,4];d2 = [1,1,1,1]; x1 = [d1,d1,d1]';

x2 = [d2,2*d2,3*d2]';

y = [40, 51, 65, 72, 38, 46, 53, 67, 31, 39, 48, 56]';

X = [ones(size(x1)) x1 x2]; a = X\y

Y = X*a;

MaxErrPerc = 100*max(abs((Y-y)./y))

p = [26.1,27,28.2,29,29.8,30.6,31.1,31.3,31,30.5];

t = 1:10;

tp = 1:0.05:10;

coeff1 = polyfit(t,p,1);

coeff2 = polyfit(t,p,2);
coeff3 = polyfit(t,p,3);

p1 = polyval(coeff1,tp);

p2 = polyval(coeff2,tp);

p3 = polyval(coeff3,tp);

plot(t,p,'o',tp,p1,tp,p2,tp,p3,'--'), xlabel('Time (secs)'),ylabel('Pressure (psi)')

b) res2 = p - polyval(coeff2,t);

res3 = p - polyval(coeff3,t);

plot(t,res2,t,res2,'o',t,res3,'--',t,res3,'o'),xlabel('Time (sec)'),ylabel('Residuals (psi)'), gtext('2nd


Order'),gtext('3rd Order')

mu = mean(p);

S = sum((p-mu).^2);

J2 = sum((polyval(coeff2,t)-p).^2);

J3 = sum((polyval(coeff3,t)-p).^2); r22 = 1-J2/S

r23 = 1-J3/S

T = 10:10:90;

S = [35,35.6,36.25,36.9,37.5,38.1,38.8,39.4,40];

coeff = polyfit(T,S,1)

Sest = coeff(1)*25 + coeff(2)

Tplot = 10:0.1:90;

Splot = coeff(1)*Tplot+coeff(2);

plot(T,S,'o',Tplot,Splot),xlabel('T'),ylabel('S')

You might also like