Tests - % % % % % % % % % % % % % % % NDEMO1.M Solve y' =...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
% % NDEMO1.M Solve y' = exp(-2x)-y with y(0) = 1 using Euler Method % % This is the Matlab version of the class demo used to illustrate the basics % of the Euler method. It calls the EULER function file to actually implement % the method. The solution vector is plotted along with the exact solution % to demonstrate the improved accuracy obtained with smaller step sizes (increased N). % % Some additional computations are also performed to extract intermediate results % for comparison to hand calculations. % % The function file EQN1.M containing the function definition is also required. % % File prepared by J. R. White, UMass-Lowell (Feb. 2005) % % % getting started clear all; close all; nfig = 0; % % define some initial parameters xo = 0; xf = 0.5; yo = 1; % % loop over different number of intervals (N) N = input('Input number of intervals, N, over the range [0 0.5] for EQN1: '); % while N ~= 0 % get numerical solution [x,y] = euler('eqn1',xo,xf,yo,N); % get function evaluation for comparison to hand calcs
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/01/2009 for the course PSTAT 120A taught by Professor Mackgalloway during the Spring '08 term at UCSB.

Page1 / 4

Tests - % % % % % % % % % % % % % % % NDEMO1.M Solve y' =...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online