1
$\begingroup$

I'm in need of some help with matlab code. I'm working on a problem which gives the following system:

$$x'=x^2 - x - y$$

$$y'=x-y$$

We are asked to solve the system numerically starting with $(x(0), y(0))=(-0.3,-0.3)$ for $t \in [0,10]$. Additionally, we are asked to plot the solution in a phase plane and also as a function of time.

My initial reaction is to try and use the ode45 function, then plot the $x$ and $y$ components as functions of time. The thing that I'm really having trouble with is plotting the phase plane...

Any help/links/advice is greatly appreciated!

$\endgroup$
  • 2
    $\begingroup$ For the phase plane and solution curve, are you using the stuff here matlab.cheme.cmu.edu/2011/08/09/…? $\endgroup$ – Moo Jan 27 '17 at 0:17
  • 1
    $\begingroup$ @Moo that was very helpful! I wasn't aware of that site, but I'm glad/thankful you sent it my way. Thank you very much--it did the trick for me. $\endgroup$ – George Oscar Bluth Jan 27 '17 at 2:27
  • $\begingroup$ Glad it was of service and that you resolved your issues! Regards. $\endgroup$ – Moo Jan 27 '17 at 2:29
0
$\begingroup$

The phase portrait of a system of two first-order ODEs can be obtained in a similar manner as described in this post, e.g. using Matlab's quiver function. Otherwise, one can plot several trajectories $(x (t), y (t))$ obtained by numerical integration (here with ode45) and having different initial conditions.

$\endgroup$
-1
$\begingroup$

Since this is a system of first order ordinary differential equation, I recommend you try to use 4-th order Runge-Kutta method to numerically solve the problem.

A very detailed description of 4-th order Runge-Kutta Method could be found at Runge-Kutta Method.

$\endgroup$
  • 1
    $\begingroup$ This does not answer the question and the question already indicates that ode45 is being used, which is superior to a generic RK4 scheme. $\endgroup$ – horchler Jan 27 '17 at 0:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.