I want the phase portrait show arrow direction
5 次查看(过去 30 天)
显示 更早的评论
I have coding matlab about phase portrait using equiver for add arrow direction (direction field) but arrow direction didn't clearly visible. This is coding matlab I use
This is the coding function
function dy=fungsipotretfasepemodelanedit(t,y)
global k a1 a2 b1 b2 e1 e2 m r q s w1 w2 ;
dy=zeros(5,1);
dy(1)= k+(e2*y(1)*y(2))-(a1*y(1)*y(3))-(e1*y(1)*y(2))-(m*y(1))-(b1*y(1)*y(4)) ;
dy(2)=(e1*y(1)*y(2))-(a2*y(2)*y(3))-(b2*y(2)*y(4))-(m*y(2))-(e2*y(1)*y(2));
dy(3)= (a1*y(1)*y(3))+(a2*y(2)*y(3))-(w1*y(3))-(m*y(3))-(r*y(3))-(s*y(3)*y(4));
dy(4)= (b1*y(1)*y(4))+(b2*y(2)*y(4))-(m*y(4))-(w2*y(4));
dy(5)= (w1*y(3))+(w2*y(4))+(s*y(3)*y(4))-(m*y(5))-(q*y(5));
end
this is the coding for run phase portrait
clc; close all; clear all;
figure1 = figure ;
axes1 = axes ( 'Parent' , figure1 , 'fontsize' , 13 ) ;
grid on;
box(axes1,'on') ;
hold(axes1,'all') ;
plotArrows = @(m) quiver(m(:,1),m(:,2), gradient(m(:,1)), gradient (m(:,2)));
global k e1 e2 a1 a2 b1 b2 m r q w1 w2 s;
k=40;
e1=0.07;
e2=0.05;
a1=0.08;
a2=0.02;
b1=0.07;
b2=0.03;
m=0.2;
r=0.03;
q=0.05;
w1=0.4;
w2=0.47;
s=0.02;
[t1,y1]=ode45(@fungsipotretfasepemodelanedit,[0 1000],[20 20 10 20 5]);
[t2,y2]=ode45(@fungsipotretfasepemodelanedit,[0 1000],[20 18 10 50 20]);
[t3,y3]=ode45(@fungsipotretfasepemodelanedit,[0 1000],[50 10 90 40 20]);
[t4,y4]=ode45(@fungsipotretfasepemodelanedit,[0 1000],[10 50 90 40 10]);
figure(1);
plot(y1(:,1), y1(:,2),'blue',y2(:,1), y2(:,2),'red',y3(:,1),y3(:,2),'green',y4(:,1),y4(:,2),'black','linewidth',2);
plotArrows(y1),
plotArrows(y2),
plotArrows(y3),
plotArrows(y4),
legend('Nilai Awal 1','Nilai Awal 2','Nilai Awal 3','Nilai Awal 4');
xlabel('Jumlah Populasi Rentan yang Memiliki Berat Badan Normal');
ylabel('Jumlah Populasi Rentan yang Obesitas');
0 个评论
回答(1 个)
Simon Chan
2023-2-19
The Auto Scale property in function quiver may make the arrow length looks small.
You may adjust the AutoScaleFactor to a large value in your case as follows:
plotArrows = @(m) quiver(m(:,1),m(:,2), gradient(m(:,1)), gradient(m(:,2)),'AutoScaleFactor',10);
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Array and Matrix Mathematics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!