Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
Eleftherios
Eleftherios el 7 de Dic. de 2022
Respondida: Sam Chak el 7 de Dic. de 2022
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

Respuestas (2)

Bora Eryilmaz
Bora Eryilmaz el 7 de Dic. de 2022
Editada: Bora Eryilmaz el 7 de Dic. de 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 el 7 de Dic. de 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

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by