'Matlab says that the problem is at (t), i want to use ode45

1 visualizzazione (ultimi 30 giorni)
function dxdt = odefun (t,x)
dxdt = zeros(3,1);
dxdt(1)= -(8/3)*x(1)+x(2)*x(3);
dxdt(2)= -10*x(2)+10*x(3);
dxdt(3)= -x(3) -x(2)*x(1)+28*x(2);
end

Risposte (2)

Bora Eryilmaz
Bora Eryilmaz il 7 Dic 2022
Modificato: Bora Eryilmaz il 7 Dic 2022
As long as you call your function the right way, it should work:
ode45(@odefun, [0 10], [1 1 1])
function dxdt = odefun (t,x)
dxdt = zeros(3,1);
dxdt(1)= -(8/3)*x(1)+x(2)*x(3);
dxdt(2)= -10*x(2)+10*x(3);
dxdt(3)= -x(3) -x(2)*x(1)+28*x(2);
end

Sam Chak
Sam Chak il 7 Dic 2022
Guess you probably want to view the Lorenz attractor.
[t, x] = ode45(@odefun, [0 100], [1 1 1]);
plot3(x(:,1), x(:,2), x(:,3))
az = 90;
el = 0;
view(az, el)
function dxdt = odefun(t, x)
dxdt = zeros(3,1);
dxdt(1) = - (8/3)*x(1) + x(2)*x(3);
dxdt(2) = - 10*x(2) + 10*x(3);
dxdt(3) = - x(3) - x(2)*x(1) + 28*x(2);
end

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by