Now that we have seen Euler in action, let's return to examiningthe content of the M-File Euler.m. We have already explained thefirst line, where we defined the parameters our function takes. Tosee the meaning behind the third and fourth lines, type:
>> x = zeros(10,1);y = zeros(10,1);[x,y]
Thus we can see that the third and fourth lines of our M-Filezero out the contents of our arrays x and y before we begin. Now,you'll continue examining our code.
Question: In your Worddocument, briefly explain what is happening in each remaining lineof the M-File Euler.m.
The M-File is:
function [x,y] = Euler(h, x0, y0, interval_length, func)nsteps = floor(interval_length/h) + 1;x = zeros(nsteps,1);y = zeros(nsteps,1);x(1) = x0;y(1) = y0;for i=2:nsteps y(i) = y(i-1) + h* func(x(i-1), y(i-1)); x(i) = x(i-1) + h;end