function [t, y] = euler_explicite(f, y0, t0, tf, h) t = t0:h:tf; y = zeros(size(t)); y(1) = y0; for n = 1:length(t)-1 y(n+1) = y(n) + h * f(t(n), y(n)); end end in matlab
main.m
function[t, y] = euler_explicite(f, y0, t0, tf, h) t = t0:h:tf;
y = zeros(size(t));
y(1) = y0;
for n = 1:length(t)-1 y(n+1) = y(n) + h * f(t(n), y(n));
endend