How to plot this phase portrait correctly?

7 Ansichten (letzte 30 Tage)
Levente Kis
Levente Kis am 26 Apr. 2020
Kommentiert: Ameer Hamza am 26 Apr. 2020
The following ODE describes a nonlinear mechanical system:
where are numerically given system parameters.
I have to plot the phase portrait of this ODE. I tried the following:
I tried the following code:
clear all;
clc;
%data:
l=0.1;
a=0.06;
m=1;
s=1200;
[x,y]=meshgrid(-0.12:.0005:0.12, -0.12:.0005:0.12);
dx=y;
dy=-(s/m)*x.*(1-l*(sqrt(x.^2+a^2))).^(-1);
streamslice(x,y,dx,dy);
title('Phase portrait')
axis tight equal
The system has 3 equilibrium points: in (0;0) there is a saddle, in (0.08;0) there is a centre, and in (-0.08;0) there is also a centre. So the phase portrait should look like the following:
Yet, Matlab gives me the following:
This isn't look good. What could be the problem, and how should I fix my code, to get a better result?

Antworten (1)

Ameer Hamza
Ameer Hamza am 26 Apr. 2020
You wrote the equation for dy wrong. Also, the range of y-values is also small. Try this
clear all;
clc;
%data:
l=0.1;
a=0.06;
m=1;
s=1200;
[x,y]=meshgrid(-0.12:0.01:0.12, -1:0.2:1);
dx = y;
dy = -(s/m)*x.*(1-l./sqrt(x.^2+a^2));
streamslice(x, y, dx, dy, 'filled');
title('Phase portrait')
axis tight
  2 Kommentare
Levente Kis
Levente Kis am 26 Apr. 2020
Thank you! It works.
Although the arrows looks pretty ugly, is there a solution for that?
Ameer Hamza
Ameer Hamza am 26 Apr. 2020
You can try quiver instead of streamslice. For example,
clear all;
clc;
%data:
l=0.1;
a=0.06;
m=1;
s=1200;
[x,y]=meshgrid(-0.15:0.01:0.15, -1:0.2:1);
dx = y;
dy = -(s/m)*x.*(1-l./sqrt(x.^2+a^2));
streamslice(x, y, dx, dy);
% hold on
quiver(x, y, dx, dy);
title('Phase portrait')
axis tight

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Numerical Integration and Differential Equations finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by