How can I add Direction arrows in this Phase Portrait I mean arrows in the Direction of velocity
2 次查看(过去 30 天)
显示 更早的评论
clear
clc
clf
close all
k1 = 3;
k_1 = 1;
k2 = 3;
k3 = 0.6;
k_3 = 1;
k4 = 3;
f = @(t,a) [k_1*a(2)-k1*a(1)-k3*a(1)*a(2)-k_3*a(3);
k1*a(1)-(k_1+k2)*a(2)-k3*a(1)*a(2)+(k4+k_3)*a(3);
k3*a(1)*a(2)-(k4+k_3)*a(3)];
[t,a] = ode45(f,[0 100],[4.1 1.1 0]); % Runge-Kutta 4th/5th order ODE solver
plot3(a(:,1),a(:,2),a(:,3))
hold on
grid on
xlabel('S','fontsize',12)
ylabel('C1','fontsize',12)
zlabel('C2','fontsize',12)
[t,a] = ode45(f,[0 100],[4 1 0]); % Runge-Kutta 4th/5th order ODE solver
plot3(a(:,1),a(:,2),a(:,3))
[t,a] = ode45(f,[0 100],[3.9 .9 0]); % Runge-Kutta 4th/5th order ODE solver
plot3(a(:,1),a(:,2),a(:,3))
[t,a] = ode45(f,[0 100],[3.8 .8 0]); % Runge-Kutta 4th/5th order ODE solver
plot3(a(:,1),a(:,2),a(:,3))
[t,a] = ode45(f,[0 100],[3.7 .7 0]); % Runge-Kutta 4th/5th order ODE solver
plot3(a(:,1),a(:,2),a(:,3))
[t,a] = ode45(f,[0 100],[3.6 .6 0]); % Runge-Kutta 4th/5th order ODE solver
plot3(a(:,1),a(:,2),a(:,3))
[t,a] = ode45(f,[0 100],[3.5 .5 0]); % Runge-Kutta 4th/5th order ODE solver
plot3(a(:,1),a(:,2),a(:,3))
[t,a] = ode45(f,[0 100],[3.4 .4 0]); % Runge-Kutta 4th/5th order ODE solver
plot3(a(:,1),a(:,2),a(:,3))
[t,a] = ode45(f,[0 100],[3.3 .3 0]); % Runge-Kutta 4th/5th order ODE solver
plot3(a(:,1),a(:,2),a(:,3))
[t,a] = ode45(f,[0 100],[3.2 .2 0]); % Runge-Kutta 4th/5th order ODE solver
plot3(a(:,1),a(:,2),a(:,3))
[t,a] = ode45(f,[0 100],[3.1 .1 0]);
plot3(a(:,1),a(:,2),a(:,3))
hold off
7 个评论
Rik
2021-12-21
Original question content (the attached SC1C2best.m file can't be restored from Google cache):
clear
clc
clf
close all
k1 = 3;
k_1 = 1;
k2 = 3;
k3 = 0.6;
k_3 = 1;
k4 = 3;
f = @(t,a) [k_1*a(2)-k1*a(1)-k3*a(1)*a(2)-k_3*a(3);
k1*a(1)-(k_1+k2)*a(2)-k3*a(1)*a(2)+(k4+k_3)*a(3);
k3*a(1)*a(2)-(k4+k_3)*a(3)];
[t,a] = ode45(f,[0 100],[4.1 1.1 0]); % Runge-Kutta 4th/5th order ODE solver
plot3(a(:,1),a(:,2),a(:,3))
hold on
grid on
xlabel('S','fontsize',12)
ylabel('C1','fontsize',12)
zlabel('C2','fontsize',12)
[t,a] = ode45(f,[0 100],[4 1 0]); % Runge-Kutta 4th/5th order ODE solver
plot3(a(:,1),a(:,2),a(:,3))
[t,a] = ode45(f,[0 100],[3.9 .9 0]); % Runge-Kutta 4th/5th order ODE solver
plot3(a(:,1),a(:,2),a(:,3))
[t,a] = ode45(f,[0 100],[3.8 .8 0]); % Runge-Kutta 4th/5th order ODE solver
plot3(a(:,1),a(:,2),a(:,3))
[t,a] = ode45(f,[0 100],[3.7 .7 0]); % Runge-Kutta 4th/5th order ODE solver
plot3(a(:,1),a(:,2),a(:,3))
[t,a] = ode45(f,[0 100],[3.6 .6 0]); % Runge-Kutta 4th/5th order ODE solver
plot3(a(:,1),a(:,2),a(:,3))
[t,a] = ode45(f,[0 100],[3.5 .5 0]); % Runge-Kutta 4th/5th order ODE solver
plot3(a(:,1),a(:,2),a(:,3))
[t,a] = ode45(f,[0 100],[3.4 .4 0]); % Runge-Kutta 4th/5th order ODE solver
plot3(a(:,1),a(:,2),a(:,3))
[t,a] = ode45(f,[0 100],[3.3 .3 0]); % Runge-Kutta 4th/5th order ODE solver
plot3(a(:,1),a(:,2),a(:,3))
[t,a] = ode45(f,[0 100],[3.2 .2 0]); % Runge-Kutta 4th/5th order ODE solver
plot3(a(:,1),a(:,2),a(:,3))
[t,a] = ode45(f,[0 100],[3.1 .1 0]);
plot3(a(:,1),a(:,2),a(:,3))
hold off
回答(1 个)
Walter Roberson
2021-12-19
编辑:Walter Roberson
2021-12-19
You cannot add velocity direction vectors to that plot, as none of your variables are velocity, and none of your variables allow velocity to be calculated (for example they are not acceleration.)
In order to plot velocity direction vectors, you need one of a small number of things:
- x and y, or x and y and z components of the velocity at a series of x and y, or x and y and z locations
- magnitude and direction components of the velocity at a series of x and y, or x and y and z locations
- x and y, or x and y and z components of the velocity at a series of 2d polar or 3d spherical or 3d cylindrical coordinates
- magnitude and direction components of the velocity at a series of 2d polar or 3d spherical or 3d cylindrical coordinates
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!