Circle and spiral phase portraits in MATLAB

126 Views Asked by At

I am having some trouble drawing these phase portraits

enter image description here

For 2.a when solving $[\dot{y_1},\dot{y_2}]^T = C * [y_1,y_2]^T$

We get $\dot{y_1} = -b*y_2$ and $\dot{y_2} = b*y_1$ and thus can solve

$\ddot{y_1} = -b^2y_1$ and $\ddot{y_2} = -b^2y_2$ to find

$y_1 = C_1 \sin(bx) + C_2 \cos(bx)$ and $y_2 = C_3 \sin(bx) + C_4 \cos(bx)$

The only way I am able to plot it on MATLAB correctly is when I take $C_2 = C_3=0$ and $C_1 = C_4$ (otherwise I will get an ellipse)

I understand why $\sin x,\cos x$ gives a circle but that is only a specific combination of coefficients. The phase diagram for C when plotted using $y_1 = C_1 \sin(bx) + C_2\cos(bx)$ and $y_2 = C_3\sin(bx) + C_4\cos(bx)$ gives me ellipses. How can we say that the phase diagram of $C$ are circles if this is only true in specific cases and no boundary conditions have been given.

Also for 2.b I don't know how to solve that system so could someone please explain how it corresponds to a spiral so I can try it on MATLAB

I have attached my code and would be grateful is someone could show me the MATLAB code for the spiral.

enter image description here

1

There are 1 best solutions below

0
On

2a

I'm going to start where you left, but hopefully you will see that this can be done in fewer steps than you did

\begin{align} y_1(t) &= C_1 \sin bt + C_2 \cos b t \\ y_2(t) &= C_3 \sin bt + C_4 \cos b t \tag{1}\\ \end{align}

As you say $\dot{y}_1 = -b y_2$, which translates to

$$ bC_1 \cos bt - bC_2 \sin b t = -b(C_3 \sin bt + C_4 \cos b t) ~~~\Rightarrow~~~ C_1 = -C_4, C_2 = C_3 $$

Replace that back in Eq. (1) and you get

\begin{align} y_1(t) &= C_1 \sin bt + C_2 \cos b t \\ y_2(t) &= C_2 \sin bt - C_1 \cos b t \tag{2}\\ \end{align}

Now evaluate these equations at $t=0$,

\begin{align} y_1(0) &= C_2 \\ y_2(0) &= -C_1\\ \end{align}

Again, if you replace that in Eq. (2) you get

\begin{align} y_1(t) &= -y_2(0) \sin bt + y_1(0) \cos b t \\ y_2(t) &= y_1(0) \sin bt + y_2(0) \cos b t \tag{3}\\ \end{align}

or in matrix form

$$ \pmatrix{y_1(t) \\ y_2(t)} = \pmatrix{\cos bt & -\sin bt \\ \sin bt & \cos bt} \pmatrix{y_1(0) \\ y_2 (0)} \tag{4} $$

Or more compact

$$ {\bf y}(t) = A {\bf y}(0) $$

turns out the matrix $A$ is the exponential matrix of $C$: $A = e^{tC}$. Which is calculated very simply for this case as $A = U^{-1}{\rm diag}(\lambda_1 t, \lambda_2 t) U$, where $U$ is the eigenvector matrix of $C$ and $\lambda$ its eigenvalues.

In any case, if you want to plot Eq. (4) you just need to select an initial point and multiply times a matrix.

2b

This is trivial if you calculate the matrix as before. But if you are not comfortable doing that, try with solutions of the form $y\sim e^{\pm \lambda t}$, where $\lambda$ are the eigenvalues of $C$