title: Solving a system of ODEs in MATLAB?
body: <p>this is my first time posting, so if you need anymore info or I havn't done something correct please let me know!</p>
  
  <p>I want to plot a system of <strong>ODES</strong>, which would be no problem as I would do the following;</p>
  
  <pre><code>F=@(t,x) [
  .the RHS of my first order ODES.
  ];
  
  
  [t x]=ode45(F,[Range], [Initial conditions]);
  </code></pre>
  
  <p>Where a vector would be created containing x'(1), x'(2),... where x(1), x(2) would be the time dependant variable.</p>
  
  <p>However my system is a little more complicated. I have 6 differential equations which are made up of equations that include differential equations and the time dependant variables. For example, the RHS of my ODES are something like 
  2*x(2)*x'(1)*f(a)</p>
  
  <p>Where f(a) could be another function based on constants, a.</p>
  
  <p>I have set up my code in the following order;</p>
  
  <p>Constants, then equations of the form f(a), then my differential equations followed by the ode45 solver and the plot commands. However I am getting several errors "Undefined function or variable" as early equations depend on variables/equations that are not defined until later.</p>
  
  <p>Thank you ever so much for you help :)</p>
  
  <p>As suggested, here an example of the type of my code;</p>
  
  <pre><code>`%Constants
  a=34
  b=31
  c=20
  %Equations
  A=b*cos(2*pi)
  B=a*EQ1
  C=c*x(2)
  %DifferentialEquations
  EQ1=x(1)*A
  EQ2=(EQ3-EQ1)*(B-C)
  EQ3=x(2)*x(3)
  F=@(t,x) [EQ1;EQ2;EQ3;];[t x]=ode45(F,[0 10], [0 0 0 ]);
  </code></pre>
  
  <p>Provides the error.
  Produces the undefined function or variable 'DEQ1A'.</p>