UMD Web Site

Page Content   Main Links   Page Links   Utility Links   Search   Footer Links

Department of Mathematics

Return to Previous Page  

The ODES Function 

Save in a text file with the name odes.m

function [x,y] = odes(ydot,interval, y0, h)

% A replacement for MATLAB's ode45 for Octave

% Written by A.O. Hausknecht Spring 2010

x0  = interval(1); % The minimum x-value

x1  = interval(2); % The maximum x-value

x = x0:h:x1; 

% Generate an approximate solution for the differential

% equation with the initial condition y(x0)= y0.

y = lsode(ydot,[y0],x); 

hold on; % Enable plot overlay so plots will be combined

% Generate a vector of x-values using a setsize h = 0.1

% Plot the solution as a curve

size=2; % linewidth and marker size

plot(x,y,'linewidth', size);

% Overlay a the solution points

plot(x,y,'*', 'markersize', size+1);

% Overlay a the solutions initial point in red

plot(x0, y0,'+r','markersize',size+2);

hold off; % Disable plot overlay

% Use the transpose operator to the row vector of

% x-values into a column vector (to match MATLAB's ode45).

x = x'; 

end

Last Updated On: 3/8/10

Contact Info:

Email: webdevelopment@umassd.edu - UMass Dartmouth Web Development Team

Main Links

Page Links

Utility Links

Search

 
Text Only Options

Top of page


Text Only Options

Open the original version of this page.

Usablenet Assistive is a UsableNet product. Usablenet Assistive Main Page.