MATLAB: ex3

← 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)
x0 = 0;
xf = 7;
y0 = [0 0 0.469599];

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

% Integrate by ODE45 the derivative functions
% defined in file EX3F.M and assign the
% solution vector to maxrix [x,y]
[x,y] = ode45 ('ex3f',[x0 xf],y0,options);

% Plot the numerical solution vector [x,y]
figure
plot(x,y(:,1),'r-');
hold on
plot(x,y(:,2),'b-');
hold on
plot(x,y(:,3),'k-');
title('ChE585 EXAMPLE-3'); grid;
xlabel('x-axis'); ylabel('y-axis');
text(0.5,3.75,'red: y(1)=f, numerical');
text(0.5,3.25,'blue: y(2)=dfdeta, numerical');
text(0.5,2.75,'black: y(3)=d2fdeta2, numerical');
53 successful steps
1 failed attempts
325 function evaluations

EX3 01

Published with MATLAB® 7.0