Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // =============================================================================
- // EXAMPLE 1 - Basic equation that only takes in 't' with each execution.
- // example from matlab converted to the syntax you use.
- f = @(t,y) [2*t;]
- [t,y] = ode45(f, [0 5], 0);
- // =============================================================================
- // EXAMPLE 2 - More complex equation. In addition to taking in 't' for each execution, it also takes in two other variables that you've supplied.
- f = @(t,y) [2*t+x(1)+x(2);]
- [t,y] = ode45(@(f, [0 5], [1000, 5000], 0);
- // The first time the equation runs, with t=0, the function would have these values "2*0+1000+5000"
- // Now, when f is run the function will have 't' supplied several times as the values between 0 and 5. You passed the time (x axis) in as [0 5], and it knows how to turn that in to 0,1,2,3,4,5 and calls your function that many times.
- // The other variables, x(1) and x(2), are filled in with 1000 and 5000, respectively.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement