This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: 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, , 8) (3) 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 x exp(-x/5) cos(x 2 ) -1 In step one, the handles 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 . To obtain the numerical solution to this initial value problem, we will....
View Full Document
This note was uploaded on 06/01/2009 for the course MATH 245 taught by Professor Alexander during the Spring '07 term at USC.
- Spring '07