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

조회 수: 1 (최근 30일)
Eleftherios
Eleftherios 2022년 12월 7일
답변: Sam Chak 2022년 12월 7일
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