Bisection method + Differential equation question
이전 댓글 표시
I need to calculated 100 values using differential equation and bisection method, but it is giving me only 1 value. I have 100 a1 and a2 values initially, and the time needed when m>1 should be calculated. this is where I got stuck..
tmax=10;
tmin=0;
error=tmax-tmin;
for i=1:100
dmdt=@(t,m)[-m(1).*a1(i);m(1).*a1(i)-m(2).*a2(i)];
while error>10^-5
treal=(tmax+tmin)/2;
[t,m]=ode45(dmdt,[0 treal(i)],[1;0]);
if m(end,2)>1
tmax=treal(i);
else tmin=treal(i);
end
error=tmax-tmin;
end
end
treal
I have it as treal and it is giving me only 1 value instead of 100.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!