Professional Documents
Culture Documents
Variables For Oxygen Concentration: %tick 1
Variables For Oxygen Concentration: %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
figure;
plot(terms,VB,'-k.','MarkerSize',20); title('Oxygen Conc. at t=.05 seconds vs. term
Approximate Relative Error 2 terms
erra1 =
1.5821