how to calculate synchronization error diagrams

1 visualización (últimos 30 días)
凯 何
凯 何 el 13 de Abr. de 2024
Editada: Arnav el 18 de Sept. de 2024
% 定义系统参数
parameters = [1; 1; 4.92; 1; 1; 0; 1183; 303900]
% 定义初始条件
X0 = [0.1; 0.2; 0.3; 1.5; -1; 2]
% 定义时间跨度
tspan = [0 10];
% 定义系统方程(4.3)
[time, Y] = ode45(@(t, Y) error_system(t, Y, parameters), tspan, X0);
function dydt = error_system(t, X, Y, parameters)
% 系统参数
a = parameters(1);
b = parameters(2);
h = parameters(3);
v1 = parameters(4);
v2 = parameters(5);
k1 = parameters(6);
k2 = parameters(7);
k3 = parameters(8);
% 从 Y 中提取误差项
Y(1)=X(4) - X(1);
Y(2)=X(5) - X(2);
Y(3)=X(6) - X(3);
e1 = Y(1);
e2 = Y(2);
e3 = Y(3);
% 计算导数
dydt = [-v1*e1 + h*e2 - a*X(2)*X(3) - k1*e1;
h*e1 - v2*e2 + a*X(4)*X(6) - a*X(1)*X(3) - k2*e2;
a*X(4)*X(5) -a*X(1)*X(2) - b*e3 - k3*e3];
end

Respuestas (1)

Arnav
Arnav el 18 de Sept. de 2024
Editada: Arnav el 18 de Sept. de 2024
I understand that you are trying to solve the following system of equations.
The first system is shown below:
The second system needs to be rewritten in the following form as it is currently under-determined in the code:
After the first system is solved, the 2nd system would no longer be under-determined. Assuming the initial conditions for the variables to be , the initial condition for the error becomes .
Since the first system is independent of the second, it can be solved first as shown:
% Solve the first system
[t1, sol1] = ode45(@(t, y) firstSystem(t, y, a, b, h, v1, v2), tspan, [0.1 0.2 0.3]);
% Function for the first system of equations
function dydt = firstSystem(~, y, a, b, h, v1, v2)
x1 = y(1); y1 = y(2); z1 = y(3);
dydt = [ h*y1 - v1*x1 - a*y1*z1;
h*x1 - v2*y1 + a*x1*z1;
a*x1*y1 - b*z1 ];
end
Then the second system can be solved by using the result of first system. This can be done as shown:
% Solve the second system
[t2, sol2] = ode45(@(t, e) secondSystem(t, e, sol1, t1, a, b, h, v1, v2, k1, k2, k3), tspan, [1.4 -1.2 1.7]); % Last argument is initial conditions
function dedt = secondSystem(t, e, sol1, t1, a, b, h, v1, v2, k1, k2, k3)
% Interpolate x1, y1, z1 from the first system's solution
x1 = interp1(t1, sol1(:, 1), t);
y1 = interp1(t1, sol1(:, 2), t);
z1 = interp1(t1, sol1(:, 3), t);
ex = e(1); ey = e(2); ez = e(3);
dedt = [ -v1*ex + h*ey + a*y1*z1 - a*(ey+y1)*(ez+z1) - k1*ex;
h*ex - v2*ey + a*(ex+x1)*(ez+z1) - a*x1*z1 - k2*ey;
a*(ex+x1)*(ey+y1) - a*x1*y1 - b*ez - k3*ez ];
end
The error can be plotted against time using plot(t2, sol2) command.
The interp1 function is used to interpolate values from the solution of the first system. You can learn more about interp1 function by referring to its documentation page:
Hope it helps.

Categorías

Más información sobre Modeling en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by