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 CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by