You are on page 1of 3

Table of Contents

Variables for Oxygen Concentration ....................................................................................... 1


Part A ............................................................................................................................... 1
Part B ............................................................................................................................... 2

Variables for Oxygen Concentration


D = (1.6*10^-5);
N_O = 84;
G1 = 45;
G2 = 255;
L = 0.006;
x = L/2;
p=pi;
V1 = N_O - ((G2*x)/2*D)*(L-x);
V2=((4*(G2-G1)*L^2)/D);
t=[0:.01:1];
e = exp(1);
A = 0;
n1 = [];
t1=1; %tick 1

Part A
S = @(t,n) ((1/((n*p)^3))*(e.^((-1*(n*p)^2)*(D*t/(L^2))))*sin((n*p*x)/L));
V(t1, :) = V1 + V2*S(t,1); %1 term concentration approx.
while (t1 < 4) %use loop to add successive terms
t1 = t1+1;
N= (2* t1) - 1;
V(t1, :) = V(t1-1,:) + V2*S(t,N);
end

figure;
plot(t,V); title('Change in Rate for Oxygen Concentration'); xlabel('time(s)'); yla
legend('1 term','2 terms','3 terms','4 terms','Location', 'NE');

Part B
VB = V(:,6); % get values of V at time = .05 seconds
terms=[1 2 3 4]; % for plot
erra1 = abs((V(2) - V(1))/V(2))*100; %approximate errors
erra2 = abs((V(3) - V(2))/V(3))*100;
erra3 = abs((V(4) - V(3))/V(4))*100;
disp('Approximate Relative Error
disp('Approximate Relative Error
disp('Approximate Relative Error
disp('According to the graph and

2 terms'); erra1 %display error


3 terms'); erra2
4 terms'); erra3
the approximate errors, you need to add atleast 2

figure;
plot(terms,VB,'-k.','MarkerSize',20); title('Oxygen Conc. at t=.05 seconds vs. term
Approximate Relative Error 2 terms
erra1 =
1.5821

Approximate Relative Error 3 terms


erra2 =
0.3406
Approximate Relative Error 4 terms
erra3 =
0.1243
According to the graph and the approximate errors, you need to add atleast 2 terms

Published with MATLAB R2014b

You might also like