How to plot this phase portrait correctly?

조회 수: 7 (최근 30일)
Levente Kis
Levente Kis 2020년 4월 26일
댓글: Ameer Hamza 2020년 4월 26일
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?

답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 4월 26일
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
Levente Kis
Levente Kis 2020년 4월 26일
Thank you! It works.
Although the arrows looks pretty ugly, is there a solution for that?
Ameer Hamza
Ameer Hamza 2020년 4월 26일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by