How can I change this explicit method code to the implicit method code?

조회 수: 2 (최근 30일)
민석 최
민석 최 2022년 6월 7일
편집: David Goodmanson 2022년 6월 8일
f = @(t,y) -100000*y + 99999*exp(-t);
t0 = 0; y0 =0;
h = 0.01; tn = 2;
n = (tn-t0)/h;
t(1)=t0; y(1)=y0;
for i=1:n
t(i+1) = t(i) + h;
y(i+1) = y(i) + (f(t(i),y(i))*h);
end
plot(t,y)

답변 (1개)

David Goodmanson
David Goodmanson 2022년 6월 7일
편집: David Goodmanson 2022년 6월 8일
Hi MC
I am not sure what is meant by 'implicit method', and while numerical methods are good, there is also the exact expression. The solution to
y' = -a*y + b*exp(-t) a = 100000 b = 99999
is
y = A*exp(-a*(t-t0)) + (b/(a-1))*exp(-t)
where A is determined by the initial condition y(t0) = y0
A = y0 - (b/(a-1))*exp(-t0)
In this case b/(a-1) = 1 (probably not by coincidence) so further simplification happens.

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by