Contents
Aaron Klapheck
clear, clc, home
fprintf('The date and time: %s \n', datestr(now))
The date and time: 08-Apr-2008 14:02:12
Notes
Solve 12.12 a
clear, clc, home
fprintf('The date and time: %s \n \n', datestr(now))
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('% %')
disp('% Purpose: Solve 12.12 (a) %')
disp('% %')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
Tspan = [0 30];
initc = 0;
a = 1;
[T, Y] = ode45(@SolveODE1stA,Tspan,initc,[],a);
t = [0:.1:30];
y = 1/a.*(t.^2 - 2.*t + 2 + (a - 2).*exp(-t));
figure(2)
plot(T, Y, t, y), legend('MATLAB Numeric Solution', 'Exact Solution')
The date and time: 08-Apr-2008 14:02:13
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% Purpose: Solve 12.12 (a) %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Solve 12.12 c
clear, clc, home
fprintf('The date and time: %s \n \n', datestr(now))
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('% %')
disp('% Purpose: Solve 12.12 (c) %')
disp('% %')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
Tspan = [0 30];
initc = 0;
a = 1;
b = 1;
[T, Y] = ode45(@SolveODE1st,Tspan,initc,[],a,b);
t = [0:.1:30];
y = -1/b.*(a - (a + b).*exp((b.*t.^2)./2));
figure(2)
plot(T,log(Y),t, log(y)), legend('MATLAB Numeric Solution', 'Exact Solution')
The date and time: 08-Apr-2008 14:02:15
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% Purpose: Solve 12.12 (c) %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Warning: Log of zero.