My Euler Method Error
显示 更早的评论
Question:
Consider the initial value problem: dy/dt= e−t − 3y, y(−1) = 0.
Part a: Use the MATLAB program myeuler.m from Chapter 8 to compute the Euler Method approximation to y(t) with step size h = 0.5 and n = 4 steps. The program will generate a list of ordered pairs (ti, yi). Use plot to graph the piecewise linear function connecting the points (ti, yi). Repeat with h = 0.2 and n = 10.
Code:
f = @(t,y) exp(-t)-3*y;
[t, y] = myeuler(f,-1,0,1,4);
plot(t,y)
[t, y] = myeuler(f,-1,0,1,10)
plot(t,y)
5 个评论
James Tursa
2015-10-7
You need to show us the myeuler.m code so we know what the arguments are supposed to be.
Bob
2015-10-12
编辑:Walter Roberson
2015-10-12
Walter Roberson
2015-10-12
What difficulty are you encountering? You did not ask a question.
Bob
2015-10-13
Bob
2015-10-13
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!