Getting error in ode 45

조회 수: 1 (최근 30일)
BINAY NAYAK
BINAY NAYAK 2022년 2월 28일
답변: Abolfazl Chaman Motlagh 2022년 2월 28일
function dcdt = odefun1(t,c)
dcdt = zeros(3,1);
dcdt(1) = -c(1)+20*c(2);
dcdt(2) = c(1)-40*c(2)+c(3);
dcdt(3) = 20*c(2)-c(3);
[t,c] = ode45(@odefun1,[0 10],[1;0;0]);
plot(t,c(:,1),t,c(:,2),t,c(:,3))
end
  댓글 수: 1
BINAY NAYAK
BINAY NAYAK 2022년 2월 28일
Please help me!

댓글을 달려면 로그인하십시오.

답변 (1개)

Abolfazl Chaman Motlagh
Abolfazl Chaman Motlagh 2022년 2월 28일
you put ode45 and plot in your ode function. try this : (all in one script)
[t,c] = ode45(@odefun1,[0 10],[1;0;0]);
plot(t,c(:,1),t,c(:,2),t,c(:,3))
function dcdt = odefun1(t,c)
dcdt = zeros(3,1);
dcdt(1) = -c(1)+20*c(2);
dcdt(2) = c(1)-40*c(2)+c(3);
dcdt(3) = 20*c(2)-c(3);
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