# Liapunov plot in MATLAB

I seem to do a lot of MATLAB coding… In a paper I’m studying I came across the following:

“… in which case it is a dissipative system possessing a Liapunov function … thus, released from an initial (non-equilibrium) state, typical solutions approach asymptotically stable fixed points (sinks).”

(Brown & Holmes (2001), Modelling a simple choice task: Stochastic dynamics of mutually inhibitory neural groups, Stochastics  and Dynamics, 1:2 (2001), 159-191))

So I’ve been doing a bit of background reading on system stability (in linear systems) and Liapunov functions, which can be used to prove the stability of an equilibrium of an ordinary differential equation. I plotted a simple one in MATLAB:

There isn’t really a lot of code behind it, so I’ll just post it here (I also might update this later with slightly more complicated functions):

```x = [-1:.05:1]; y = x; [x,y] = meshgrid(x,y); z = x.^2 + y.^2; figure(1) colormap(bone) surf(x,y,z) title('Liapunov equation: f(x) = x^2 + y^2')```

# Lotka-Volterra MATLAB model

I’m starting to play with dynamical systems so I figured I’d post a baby model. It essentially shows the growth of two populations co-existing together, one being the prey, the other the predators. A small time step (dt) shows that the system is stable; a larger one leads to instability and thus highlights the importance of parameter choice.

Small dt example (populations oscillate in a stable manner):

Plotting the two populations in the phase plane yields this:

Large dt example, where the population growth is without bounds:

Plotting the two populations in the phase plane yields something quite different:

As always, the code is over on my GitHub.