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!

  • 2
    For the phase plane and solution curve, are you using the stuff here http://matlab.cheme.cmu.edu/2011/08/09/phase-portraits-of-a-system-of-odes/?2017-01-27
  • 1
    @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.2017-01-27
  • 0
    Glad it was of service and that you resolved your issues! Regards.2017-01-27

2 Answers 2

0

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.

-1

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.

  • 1
    This does not answer the question and the question already indicates that `ode45` is being used, which is superior to a generic RK4 scheme.2017-01-27