Improved Euler's method

15 ビュー (過去 30 日間)
Aaron Millan
Aaron Millan 2021 年 3 月 2 日
コメント済み: Aaron Millan 2021 年 3 月 2 日
Hello! I am working on a code I tried to run last year for Euler's improved method, which uses the height of a trapezoid to find a definite integral value. My code is written below.
the first line of my code is exactly what we went over in class, so I know that part is correct; do you have any suggestions or see anything wrong with my code? Many thanks!
function y = ieuler(f,y0,t0,tn,N)
h = (tn-t0)/N;
t = t0:h:tn;
y = zeros(length(y0), N+1);
y(:,1) = y0;
for k = 1:N
e = y(:,k) + h*f(t(k), y(:,k)) ;
y(:,k+1) = y(:,k) + .5*h*(f(t(k), y(:,k))+ f(t(k+1),e));
end
  2 件のコメント
James Tursa
James Tursa 2021 年 3 月 2 日
Are you getting errors or an answer you didn't expect? What behavior are you seeing that prompted you to ask a question?
Aaron Millan
Aaron Millan 2021 年 3 月 2 日
Actually, I wanted to ask for pointers or suggestions on my code, if any. It did actually yield a vector product (which I'm very happy about)

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear Algebra についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by