How can I add Direction arrows in this Phase Portrait I mean arrows in the Direction of velocity
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Rik
am 21 Dez. 2021
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
Antworten (1)
Walter Roberson
am 19 Dez. 2021
Bearbeitet: Walter Roberson
am 19 Dez. 2021
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
2 Kommentare
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!