Sec 51
85-220 Analysis of Mechanical Systems
Winter 2014
Tutorial 7
1. Use nonlinear regression and the following set of pressure-volume data to find the best
possible values of the virial coefficients A1 and A2 for the following equation. Use that
R=[Link]/(gmol.K) and T=303K.
P(atm) 0.985 1.108 1.363 1.631
V(mL) 25.00 22.20 18.00 15.00
Solution: Answers: A1= -38.4666 mL and A2= 356.6018 mL2
R=82.05; T=303;
P=[0.985 1.108 1.363 1.631];
V=[25.000 22.200 18.000 15.000];
fminsearch(@(a)MinVirCoef(a,V,P,R,T),[-200 1])
with
function f = MinVirCoef(a,V,P,R,T)
ycalc=1+a(1)./V+a(2)./V.^2;
ymeas=P.*V/R/T;
f = sum((ymeas-ycalc).^2);
2. The solar radiation for Tucson, Arizona has been tabulated as
Month 1(J) 2(F) 3(M) 4(A) 5(M) 6(J) 7(J) 8(A) 9(S) 10(O) 11(N) 12(D)
Radiation,W/m2 144 188 245 311 351 359 308 287 260 211 159 131
a) Fit the data with the following equation to determine the coefficients a0, a1, and a2
where R and M are the radiation for the corresponding month number M.
1
b) Use the resulting equation to predict the radiation in mid August.
Solution:
a) a0= 246.1667, a1= -0.0223 and a2= -105.9675
t=[1 2 3 4 5 6 7 8 9 10 11 12]';
R=[144 188 245 311 351 359 308 287 260 211 159 131]';
Z=[ones(size(t)) sin(pi/6*t) cos(pi/6*t)];
a=(Z'*Z)\(Z'*R)
y=a(1)+a(2)*sin(t*pi/6)+a(3)*cos(pi/6*t);
plot(t,R,'o',t,y)
b) RmidAugust= 273.6146W/m2
y=a(1)+a(2)*sin(8.5*pi/6)+a(3)*cos(pi/6*8.5)
2
Sec 52
85-220 Numerical Analysis of Engineering Systems
Winter 2014
Tutorial 7
1. Three disease-carrying organisms decay exponentially in seawater according to the
following model:
p(t ) Ae 1.5t Be 0.3t Ce 0.05t
(a) Estimate the initial concentration for each organism (A, B, C) given the following
measurements:
t (hours) 0.5 1 2 3 4 5 6 7 9
p(t) 6 4.4 3.2 2.7 2 1.9 1.7 1.4 1.1
c) Use the resulting equation to predict the decay p of the organisms after 6.5 hours.
Solution:
c) A= 4.1375, B = 2.8959, C = 1.5349
t=[0.5 1 2 3 4 5 6 7 9]';
p=[6 4.4 3.2 2.7 2 1.9 1.7 1.4 1.1]';
Z=[exp(-1.5*t) exp(-0.3*t) exp(-0.05*t)];
a=(Z'*Z)\(Z'*p)
y=a(1)*exp(-1.5*t)+a(2)*exp(-0.3*t)+a(3)*exp(-0.05*t);
plot(t,p,'o',t,y)
5.5
4.5
3.5
2.5
1.5
1
0 1 2 3 4 5 6 7 8 9
d) p(6.5 hours) = 1.5213
3
y1=a(1)*exp(-1.5*6.5)+a(2)*exp(-0.3*6.5)+a(3)*exp(-0.05*6.5)
2. A material is tested for cyclic fatigue failure whereby a stress, in MPa, is applied to the
material and the number of cycles needed to cause failure is measured. The results are in
the table below. Use nonlinear regression to fit a power model to this data given by:
A1 N m
where the A1 is in MPa, and m is dimensionless. From the fit determine the values of A1
and m.
N, cycles 1 10 100 1000 10,000 100,000 1,000,000
Stress, (MPa) 1100 1000 925 800 625 550 420
Solution: Answers: A1= 1.1503 GPa and m= -0.1
clear,clc
N=[1 10 100 1000 10000 100000 1000000];
sigma=[1100 1000 925 800 625 550 420];
p=fminsearch(@(a) cyclic(a,N,sigma),[-200 1])
with
function f = cyclic(a,N,sigma)
ycalc=a(1).*N.^a(2);
f = sum((sigma-ycalc).^2);
4
Sec 53
85-220 Analysis of Mechanical Systems
Winter 2014
Tutorial 7
3. Use nonlinear regression and the following set of pressure-volume data to find the best
possible values of the virial coefficients A1 and A2 for the following equation. Use that
R=[Link]/(gmol.K) and T=303K.
P(atm) 0.985 1.108 1.363 1.631
V(mL) 25.00 22.20 18.00 15.00
Solution: Answers: A1= -38.4666 mL and A2= 356.6018 mL2
R=82.05; T=303;
P=[0.985 1.108 1.363 1.631];
V=[25.000 22.200 18.000 15.000];
fminsearch(@(a)MinVirCoef(a,V,P,R,T),[-200 1])
with
function f = MinVirCoef(a,V,P,R,T)
ycalc=1+a(1)./V+a(2)./V.^2;
ymeas=P.*V/R/T;
f = sum((ymeas-ycalc).^2);
4. The solar radiation for Tucson, Arizona has been tabulated as
Month 1(J) 2(F) 3(M) 4(A) 5(M) 6(J) 7(J) 8(A) 9(S) 10(O) 11(N) 12(D)
Radiation,W/m2 144 188 245 311 351 359 308 287 260 211 159 131
d) Fit the data with the following equation to determine the coefficients a0, a1, and a2
where R and M are the radiation for the corresponding month number M.
5
e) Use the resulting equation to predict the radiation in mid August.
Solution:
e) a0= 246.1667, a1= -0.0223 and a2= -105.9675
t=[1 2 3 4 5 6 7 8 9 10 11 12]';
R=[144 188 245 311 351 359 308 287 260 211 159 131]';
Z=[ones(size(t)) sin(pi/6*t) cos(pi/6*t)];
a=(Z'*Z)\(Z'*R)
y=a(1)+a(2)*sin(t*pi/6)+a(3)*cos(pi/6*t);
plot(t,R,'o',t,y)
f) RmidAugust= 273.6146W/m2
y=a(1)+a(2)*sin(8.5*pi/6)+a(3)*cos(pi/6*8.5)
6
Sec 54
85-220 Numerical Analysis of Engineering Systems
Winter 2014
Tutorial 7
3. Three disease-carrying organisms decay exponentially in seawater according to the
following model:
p(t ) Ae 1.5t Be 0.3t Ce 0.05t
(b) Estimate the initial concentration for each organism (A, B, C) given the following
measurements:
t (hours) 0.5 1 2 3 4 5 6 7 9
p(t) 6 4.4 3.2 2.7 2 1.9 1.7 1.4 1.1
f) Use the resulting equation to predict the decay p of the organisms after 6.5 hours.
Solution:
g) A= 4.1375, B = 2.8959, C = 1.5349
t=[0.5 1 2 3 4 5 6 7 9]';
p=[6 4.4 3.2 2.7 2 1.9 1.7 1.4 1.1]';
Z=[exp(-1.5*t) exp(-0.3*t) exp(-0.05*t)];
a=(Z'*Z)\(Z'*p)
y=a(1)*exp(-1.5*t)+a(2)*exp(-0.3*t)+a(3)*exp(-0.05*t);
plot(t,p,'o',t,y)
5.5
4.5
3.5
2.5
1.5
1
0 1 2 3 4 5 6 7 8 9
h) p(6.5 hours) = 1.5213
7
y1=a(1)*exp(-1.5*6.5)+a(2)*exp(-0.3*6.5)+a(3)*exp(-0.05*6.5)
4. A material is tested for cyclic fatigue failure whereby a stress, in MPa, is applied to the
material and the number of cycles needed to cause failure is measured. The results are in
the table below. Use nonlinear regression to fit a power model to this data given by:
A1 N m
where the A1 is in MPa, and m is dimensionless. From the fit determine the values of A1
and m.
N, cycles 1 10 100 1000 10,000 100,000 1,000,000
Stress, (MPa) 1100 1000 925 800 625 550 420
Solution: Answers: A1= 1.1503 GPa and m= -0.1
clear,clc
N=[1 10 100 1000 10000 100000 1000000];
sigma=[1100 1000 925 800 625 550 420];
p=fminsearch(@(a) cyclic(a,N,sigma),[-200 1])
with
function f = cyclic(a,N,sigma)
ycalc=a(1).*N.^a(2);
f = sum((sigma-ycalc).^2);