Help with lorenz equation

8 ビュー (過去 30 日間)
diana betancur
diana betancur 2017 年 4 月 5 日
コメント済み: Star Strider 2017 年 4 月 6 日
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 Center および File ExchangeCalculus についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by