title: Changing parameters within function for use with ODE solver
body: <p>Is is it possible to use an ODE solver, such as ode45, and still be able to 'change' values for the parameters within the called function?</p>
  
  <p>For example, if I were to use the following function:</p>
  
  <pre><code>function y = thisode(t, Ic)
  % example derivative function
  
  % parameters
  a = .05;
  b = .005;
  c = .0005;
  d = .00005;
  
  % state variables
  R = Ic(1);
  T = Ic(2);
  
  y = [(R*a)-(T/b)+d; (d*R)-(c*T)];
  </code></pre>
  
  <p>with this script:</p>
  
  <pre><code>clear all
  % Initial conditions
  It = [0.06 0.010];
  % time steps
  time = 0:.5:10;
  % ODE solver
  [t,Ic1] = ode45(@thisode, time, It);
  </code></pre>
  
  <p>everything works as I would expect.  However, I would like a way to easily change the parameter values, but still run multiple iterations of the ODE solver with just one function and one script.  However, it does not seem like I can just add more terms to the ODE solver, for example:</p>
  
  <pre><code>function y = thisode(t, Ic, P)
  
  % parameters
  a = P(1);
  b = P(2);
  c = P(3);
  d = P(4);
  
  % state variables
  R = Ic(1);
  T = Ic(2);
  
  y = [(R*a)-(T/b)+d; (d*R)-(c*T)];
  </code></pre>
  
  <p>with this script:</p>
  
  <pre><code>clear all
  % Initial conditions
  It = [0.06 0.010];
  P1 = [.05 .005 .0005 .00005]
  % time steps
  time = 0:.5:10;
  % ODE solver
  [t,Ic1] = ode45(@thisode, time, It, [], P1);
  </code></pre>
  
  <p>does not work.  I guess I know this shouldn't work, but I have been unable to come up with a solution.  I was also considering an if statement within the function and then hard coding several sets of parameters based to be used (e.g use set 1 when P == 1, set 2 when P == 2, etc) but this also did not work as I don't where to call the set to be used with an ODE.  Any tips or suggestion on how to use one function and one script with an ODE solver while being able to change parameter values would be much appreciated.  </p>
  
  <p>Thank you,
  Mike</p>