Matlab 4 solutions

# Matlab 4 solutions - MATLAB Assignment 4 Numerical Methods...

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

MATLAB Assignment 4 Numerical Methods with First Order Equations Exercise 4.1 1 function [x,y] = Euler(h, x0, y0, interval_length, func) Defines the function of x and y with 5 variables. ‘h’ is the step size for which we want to find x and y values. ‘x0’ is the initial value of x and ‘y0’ is the initial value of y. ‘interval_length’ is the length of the interval starting at x0. ‘func’ is the differential equation that will be evaluated. 2 npoints = floor( interval_length /h) + 1; Determines the number of points that will be evaluated by dividing the length of the intervals by the step size. The 1 is added to avoid missing the last point of the interval. 3 x = zeros(npoints,1); Makes a column of the x values with length of npoints and a width of 1 4 y = zeros(npoints,1); Makes a column of the y values with length of npoints and a width of 1 5 x(1) = x0; Defines the initial value of x for the differential equation 6 y(1) = y0; Defines the initial value of y for the differential equation

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 05/23/2008 for the course MATH 20D taught by Professor Mohanty during the Spring '06 term at UCSD.

### Page1 / 5

Matlab 4 solutions - MATLAB Assignment 4 Numerical Methods...

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

View Full Document
Ask a homework question - tutors are online