{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

plugin-math245lab03

# plugin-math245lab03 - Math245 Computer Lab set#3 Spring...

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

Math245 Computer Lab set #3, Spring 2009 Inline funtion Suppose now we have a function that we are interesting in how it looks like, for example, y = exp ( - x/ 5) cos ( x 2 ) - 1 (1) Step one – create a handle called f to represent this function, i.e., f = @( x ) exp ( - x/ 5) * cos ( x 2 ) - 1 (2) Step two – use function ezplot to get a quick look, ezplot ( f, 0 , 8) (3) 0 1 2 3 4 5 6 7 8 -1.8 -1.6 -1.4 -1.2 -1 -0.8 -0.6 -0.4 -0.2 0 x exp(-x/5) cos(x 2 ) -1 In step one, the handle’s name f is free to be changed to anything you like, but the format = @( x ) has to be there. In other words, if it is a function of two variables, the format should be = @( x, y ) in the case that the two variables are x and y . Notice that in describing the function, there is no need to use element-by-element operators, i.e., ( . * , etc. ) Also notice that the handle f is stored as a variable therefore a clear command will remove this handle. Solve the 1-st order ODE by using Matlab We consider the 1-st order ODE in the form dy dt = f ( t, y ) , with initial condition y (0) = y 0 . To obtain the numerical solution to this initial value problem, we will use ODE solver ode45 (Runge-Kutta 4-5th order method) in Matlab package. The simplest use of

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.

{[ snackBarMessage ]}

### Page1 / 4

plugin-math245lab03 - Math245 Computer Lab set#3 Spring...

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

View Full Document
Ask a homework question - tutors are online