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

1 次查看(过去 30 天)
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

回答(2 个)

Bora Eryilmaz
Bora Eryilmaz 2022-12-7
编辑:Bora Eryilmaz 2022-12-7
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 2022-12-7
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

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by