Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. // =============================================================================
  2. // EXAMPLE 1 - Basic equation that only takes in 't' with each execution.
  3. // example from matlab converted to the syntax you use.
  4.  
  5. f = @(t,y) [2*t;]
  6. [t,y] = ode45(f, [0 5], 0);
  7.  
  8.  
  9. // =============================================================================
  10. // 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.
  11. f = @(t,y) [2*t+x(1)+x(2);]
  12. [t,y] = ode45(@(f, [0 5], [1000, 5000], 0);
  13.  
  14. // The first time the equation runs, with t=0, the function would have these values "2*0+1000+5000"
  15.  
  16. // 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.
  17. // 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