Help with lorenz equation

8 visualizaciones (últimos 30 días)
diana betancur
diana betancur el 5 de Abr. de 2017
Comentada: Star Strider el 6 de Abr. de 2017
I used a function to call it to get the lorenz solution and then plot it
this is my code
if true
% syms s t
[t1 x1]=ode45(@lorenz,[0,10],[1;0;0])
[t2 x2]=ode45(@lorenz,[0,10],[1;0;0])
[t3 x3]=ode45(@lorenz,[0,10],[1;0;0])
figure(1)
plot(t1,x1)
figure(2)
plot(t2,x2)
figure(3)
plot(t3,x3)
figure(4)
plot(x1,x2)
figure(5)
plot(x1,x3)
figure(6)
plot(x2,x3)
end
and the function was the following
if true
% function [xdot]=lorenz(t,x)
t=0:0.001:10
xdot=[10*(x(2)-x(1));-1*x(1)*x(3)-x(2);x(1)*x(2)-(8/3)*x(3)]
end
end
any advice on how to resolve ; it is not running and just looking to continue my approach just to get it solved , thank you

Respuesta aceptada

Star Strider
Star Strider el 5 de Abr. de 2017
You’re close. Be sure you have the correct initial conditions.
This should get you started:
lorenz = @(t,x) [10*(x(2)-x(1));-1*x(1)*x(3)-x(2);x(1)*x(2)-(8/3)*x(3)]; % Anonymous Function
[T,X] = ode45(lorenz, [0 10], [1; 0; 0]);
figure(1)
plot(T, X(:,1))
grid
xlabel('Time')
figure(2)
plot(X(:,1), X(:,2))
grid
axis equal
  4 comentarios
diana betancur
diana betancur el 6 de Abr. de 2017
still is not running with the code
Star Strider
Star Strider el 6 de Abr. de 2017
The code I posted in my Answer runs without error in R2017a.
In the Wikipedia article on the Lorenz system, the MATLAB simulation has the initial conditions vector as [1 1 1], and the correct version of the Lorenz system, that being:
lorenz = @(t,x) [10*(x(2)-x(1)); x(1).*(28-x(3))-x(2); x(1)*x(2)-(8/3)*x(3)]; % Anonymous Function
Try that. It reproduces the plot in the Wikipedia article.

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by