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!