LorenzSystem, ode23

2 Ansichten (letzte 30 Tage)
Jovos
Jovos am 10 Apr. 2016
Bearbeitet: Star Strider am 10 Apr. 2016
Hi, I get a question to model the LorenzSystem. It has
dx/dt = 10(y-x)
dy/dt = -xz+28x-y
dz/dt = xy-8z/3
Setting the initial value x = 1; y = 2; z =3. It should get a graph like this. But mine is so weird.
function chaotic
clc;clear;
%LorenzSystem
y0=[1;2;3];
soln = ode23(@f,[0 100],y0)
t = linspace(0,100,300);
y(:,1)=deval(soln,t,1);
y(:,2)=deval(soln,t,2);
y(:,3)=deval(soln,t,3);
figure
plot3(y(:,1),y(:,2),y(:,3));
hold on;grid on;
end
function dxdt = f(t,x)
dxdt=[0;0;0];
dxdt(1) = 10*(x(2)-x(1));
dxdt(2) = -x(1)*x(3)+28 * x(1)- x(2);
dxdt(3) = x(1)*x(2)-8*x(3)/3;
end

Akzeptierte Antwort

Star Strider
Star Strider am 10 Apr. 2016
Bearbeitet: Star Strider am 10 Apr. 2016
It’s always best not to ‘overthink’ problems (and I admit that I’ve don that so often, I’ve lost count).
This works:
% Lorenz System
f = @(t,x) [10*(x(2)-x(1)); -x(1).*x(3)+28 .* x(1)- x(2); x(1).*x(2)-8*x(3)/3];
y0=[1;2;3];
[t,y] = ode23(f,[0 100],y0);
figure(1)
plot3(y(:,1),y(:,2),y(:,3));
grid on
Note: This is all your code, I just copy-pasted it to an anonymous function, and did a few edits.

Weitere Antworten (0)

Kategorien

Mehr zu Particle & Nuclear Physics finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by