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!