계속 오류가 나는데 이유를 모르겠습니다.,

8 vues (au cours des 30 derniers jours)
조현 김
조현 김 le 27 Juin 2020
Modifié(e) : Angelo Yeo le 27 Déc 2023
function dydt=SILAR1241421(t,y)
a=0.000000000184;
b=0.8;
c=0.7;
d=0.002;
L=1235/47041434;
M=1265/47041434;
dydt=zeros(4,1);
dydt(1)={(L-M)*y(1)-a*y(1)*y(3)};
dydt(2)={a*y(1)*y(3)-b*y(2)-M*y(2)};
dydt(3)={b*y(2)-c*y(3)-d*y(3)-M*y(3)};
dydt(4)={c*y(3)-M*y(4)};
end
[t,y]=ode45(SILAR1241421,[0,300],[47041334,0,100,0])
plot(t,y)
legend('S','E','I','R')
입력 인수가 부족합니다.
오류 발생: SILAR1241421 (line 9)
dydt(1)={(L-M)*y(1)-a*y(1)*y(3)};
9번째 라인에서 계속 오류가 납니다 도와주세요

Réponses (1)

Angelo Yeo
Angelo Yeo le 27 Déc 2023
우선, ode45 의 첫 번째 인자에는 함수 핸들을 넣어 주십시오. 또, dydt(1)={(L-M)*y(1)-a*y(1)*y(3)}; 과 같이 행렬에 cell array를 삽입할 수는 없습니다. 중괄호를 모두 지워주십시오. 결론적으로는 아래와 같이 수정하면 코드가 동작합니다.
[t,y]=ode45(@SILAR1241421,[0,300],[47041334,0,100,0])
plot(t,y)
legend('S','E','I','R')
function dydt=SILAR1241421(t,y)
a=0.000000000184;
b=0.8;
c=0.7;
d=0.002;
L=1235/47041434;
M=1265/47041434;
dydt=zeros(4,1);
dydt(1)=(L-M)*y(1)-a*y(1)*y(3);
dydt(2)=a*y(1)*y(3)-b*y(2)-M*y(2);
dydt(3)=b*y(2)-c*y(3)-d*y(3)-M*y(3);
dydt(4)=c*y(3)-M*y(4);
end

Catégories

En savoir plus sur 설치 및 라이선스 부여 소개 dans Help Center et File Exchange

Tags

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!