using runge kutta 4th order to integrate three different dynamic equation
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
% silmulating the rossler and lorenz attractor
% rossler is the driver
%lorenze as the response
% dx = [-(x(2)+ x(3));x(1) + a*x(2);b + x(3)*(x(1)-c)];
%ds = [sigma*(s(2)- s(1)); s(1) *( rho-s(3))-s(2); s(1)*s(2)-beta*s(3)];
% dz = [sigma*(z(2)- z(1));z(1) *( rho-z(3))-z(2);z(1)*z(2)-beta*z(3)];
a= 0.2; b= 0.2;c= 5.7; sigma= 16; beta= 4; rho = 45.92;g = 0;
% Define function handles
dx = [
-(x(2)+ x(3));
x(1) + a*x(2);
b + x(3)*(x(1)-c);
sigma*(s(2)- y(1))-g*(s(1)-x(1));
s(1) *( rho-s(3))-s(2);
s(1)*s(2)-beta*s(3);
sigma*(z(2)- z(1))-g*(z(1)-x(1));
z(1) *( rho-z(3))-z(2);
z(1)*z(2)-beta*z(3);
];
% setting initial conditions
epsu = [0.06;0.01;1];
epsv = [0.85;0.85;1];
epsw = [0.05;0.01;1];
dt = 0.01;
tspan = (dt:dt:1000);
x = zeros(3,tspan(end)/dt);
s = zeros(3,tspan(end)/dt);
z = zeros(3,tspan(end)/dt);
for i = 1: tspan(end)/dt
time = i*dt;
k1x = fx(epsu(i), x(i), a,b,c);
k1y = fx(epsv(i), x(i),s(i),z(i));
k1z = fx(epsw(i), x(i),s(i),z(i));
k2x = fx(x(i)+(dt/2),x(i)+(dt/2)*k1x,s(i)+(dt/2)*k1y,z(i)+(dt/2)*k1z);
k2y = fy(e(x)+(dt/2),x(i)+(dt/2)*k1x,s(i)+(dt/2)*k1y,z(i)+(dt/2)*k1z);
k2z = fz(e(x)+(dt/2),x(i)+(dt/2)*k1x,s(i)+(dt/2)*k1y,z(i)+(dt/2)*k1z);
k3x = fx(e(x)+(dt/2),x(i)+(dt/2)*k2x,s(i)+(dt/2)*k2y,z(i)+(dt/2)*k2z);
k3y = fy(e(x)+(dt/2),x(i)+(dt/2)*k2x,s(i)+(dt/2)*k2y,z(i)+(dt/2)*k2z);
k3x = fz(e(x)+(dt/2),x(i)+(dt/2)*k2x,s(i)+(dt/2)*k2y,z(i)+(dt/2)*k2z);
k4x = fx(e(x)+(dt),x(i)+(dt)*k3x,s(i)+(dt)*k3y,z(i)+(dt)*kz);
k4y = fy(e(x)+(dt),x(i)+(dt)*k3x,s(i)+(dt)*k3y,z(i)+(dt)*kz);
k4z = fz(e(x)+(dt),x(i)+(dt)*k3x,s(i)+(dt)*k3y,z(i)+(dt)*kz);
x(i+1)= e(x)+(dt/6) *(k1x +2*k2x +2*k3x +k4x);
s(i+1)= e(y)+(dt/6) *(k1y +2*k2y +2*k3y +k4y);
z(i+1)= e(z)+(dt/6) *(k1z +2*k2z +2*k3z +k4z);
end
COMMAND WINDOW: ERROR MESSAGE BELOW
Undefined function or variable 's'.
Error in silmu (line 15)
sigma*(s(2)- y(1))-g*(s(1)-x(1));
Kindly tell me where am wrong please
Antworten (1)
Jakob
am 18 Jul. 2019
In the code you shared, when you call
sigma * (s (2) - and (1)) - g * (s (1) -x (1));
s (1) * (rho-s (3)) - s (2);
s (1) * s (2) -beta * s (3);
s is not defined.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Numerical Integration and 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!