Code covered by the BSD License  

Highlights from
Numerical Methods Using MATLAB, 3e

image thumbnail

Numerical Methods Using MATLAB, 3e

by

 

20 Aug 2002 (Updated )

Companion Software

L=linsht(F1,F2,a,b,alpha,beta,M)
function L=linsht(F1,F2,a,b,alpha,beta,M)

%Input   - F1 and F2 are the systems of first-order equations 
%          representing the I.V.P.'s (9) and (10), respectively;
%          input as strings 'F1', 'F2'
%        - a and b are the endpoints of the interval
%        - alpha = x(a) and beta = x(b); the boundary conditions
%        - M is the number of steps
%Output  - L = [T' X]; where T' is the (M+1) x 1 vector of abscissas 
%          and X is the (M+1) x 1 vector of ordinates

% NUMERICAL METHODS: MATLAB Programs
%(c) 1999 by John H. Mathews and Kurtis D. Fink
%To accompany the textbook:
%NUMERICAL METHODS Using MATLAB,
%by John H. Mathews and Kurtis D. Fink
%ISBN 0-13-270042-5, (c) 1999
%PRENTICE HALL, INC.
%Upper Saddle River, NJ 07458

%Solve the system F1

Za=[alpha,0];
[T,Z]=rks4(F1,a,b,Za,M);
U=Z(:,1);

%Solve the system F2

Za=[0,1];
[T,Z]=rks4(F2,a,b,Za,M);
V=Z(:,1);

%Calculate the solution to the boundary value problem

X=U+(beta-U(M+1))*V/V(M+1);
L=[T' X];

Contact us