Help with lorenz equation

8 visualizzazioni (ultimi 30 giorni)
diana betancur
diana betancur il 5 Apr 2017
Commentato: Star Strider il 6 Apr 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

Risposta accettata

Star Strider
Star Strider il 5 Apr 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 Commenti
diana betancur
diana betancur il 6 Apr 2017
still is not running with the code
Star Strider
Star Strider il 6 Apr 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.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by