I am solving Forward Euler for dy=x*y+1, x between 0 and 1, y(0)=0 h=.25
I have gotten the error message "Index exceeds the number of array elements (5)" after rearranging the code (because I was getting other error messages). How can I clear it up?
clc; clear all;h=0.25; % step size
xmin=0;xmax=1;x=xmin:h:xmax; %x boundaries
n=length(x);y=zeros(1,n);% Initial condition
for i=1:nx0=0;dy=(x(i+1)*y(i)+1);x(i+1)=n*h;y(i+1)=y(i)+h*dy; endfigure(1)hold onplot (y,x,'b', 'linewidth',2)title ('Forward Euler')
Best Answer