Home > published > compareIntegration.m

compareIntegration

PURPOSE ^

Demonstrates convergence of Runge-Kutta 4 vs. other techniques. Requires basketball3.m

SYNOPSIS ^

function compare_integration(npts)

DESCRIPTION ^

Demonstrates convergence of Runge-Kutta 4 vs. other techniques.  Requires basketball3.m
USAGE: compare_integration(6)  
 Would plot trajectory for a basketball w/ quadratic drag with only 6
 points on entire trajectory.  Shows large error for Euler method, but RK4
 works well.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

function compare_integration(npts)
%Demonstrates convergence of Runge-Kutta 4 vs. other techniques.  Requires basketball3.m
%USAGE: compare_integration(6)
% Would plot trajectory for a basketball w/ quadratic drag with only 6
% points on entire trajectory.  Shows large error for Euler method, but RK4
% works well.

close all
figure(1)

%npts=7;
basketball3(1,100,4);
a=sprintf('Range of a Basketball in air vs. vacuum \n Euler method vs. ODE45\n Note poor fit (2nd order errors)'); 
title(a,'Fontsize',14,'Fontname','Times')
basketball3(0,npts,1);

figure(2)
basketball3(1,100,4);
a=sprintf('Range of a Basketball in air vs. vacuum \n RK-2 method vs. ODE45\n Moderately good fit (3rd order errors)');
title(a,'Fontsize',14,'Fontname','Times')
basketball3(0,npts,2);

figure(3)
basketball3(1,100,4);
a=sprintf('Range of a Basketball in air vs. vacuum \n RK-4 method vs. ODE45\n Great fit (5th Order errors)');
title(a,'Fontsize',14,'Fontname','Times')
basketball3(0,npts,3);

Generated on Fri 07-Nov-2008 13:46:59 by m2html © 2005