Help with lorenz equation

9 次查看(过去 30 天)
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

采纳的回答

Star Strider
Star Strider 2017-4-5
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 个评论
diana betancur
diana betancur 2017-4-6
still is not running with the code
Star Strider
Star Strider 2017-4-6
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by