How to plot this phase portrait correctly?
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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?
0 commentaires
Réponses (1)
Ameer Hamza
le 26 Avr 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 commentaires
Ameer Hamza
le 26 Avr 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
Voir également
Catégories
En savoir plus sur Numerical Integration and Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!