MATLAB: ex5stiff

← ChE 555: Applied Mathematics & Modeling for Chemical Engineers

echo off;
clc;
clear all;
close all;

% Initial value of indepemdent variable (t0)
% Final value of independent variable (tf)
% Initial value of dependent variable (y0)
% Integration error tolerance (tol)
t0 = 0;
tf = 3000;
y0 = [2 0];

% Define the integration options
% see ode23 help
options = odeset('RelTol',1e-3,'AbsTol',[1e-4],'Stats','on');

% Integrate by ODE45 the derivative functions
% defined in file EX4F.M and assign the
% solution vector to maxrix [t,z]
[t,y] = ode15s ('ex5stifff',[t0 tf],y0,options);
%[t,y] = ode15s ('ex5stifff',[t0 tf],y0);

% Plot the numerical solution vector [t,z]
figure
plot(t,y(:,1),'r-o');
title('ChE585 EXAMPLE-5 stiff van der Pol equations'); grid;
xlabel('x-axis'); ylabel('y1-axis');
figure
plot(t,y(:,2),'b-o');
title('ChE585 EXAMPLE-5 stiff van der Pol equations'); grid;
xlabel('x-axis'); ylabel('y2-axis');
513 successful steps
149 failed attempts
1386 function evaluations
31 partial derivatives
206 LU decompositions
1292 solutions of linear systems

EX5stiff 01 EX5stiff 02

Published with MATLAB® 7.0