MATLAB Answers

# How do I manipulate a function for Euler's method to create a function for an improved Euler's method?

3 views (last 30 days)
Chris Madrick on 3 Apr 2016
Answered: Dave Behera on 5 Apr 2016
Here is the code I have for my Euler's method. It works pretty well. I'm unclear as to what modifications I would make to this so that I may create a function for the improved Euler's method. function [ t,y ] = euler( f,tspan,y0,N ) m=length(y0); t0=tspan(1); tf=tspan(2); h=(tf-t0)./N; t=linspace(t0,tf,N+1); y=zeros(m,N+1); y(:,1) = y0'; for n=1:N y(:,n+1) = y(:,n) + h*f(t(n),y(:,n)); end t=t';y=y'; end
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Answers (1)

Dave Behera on 5 Apr 2016
The following link describes the Euler method and the improved Euler method:
You will need to modify the line inside the for loop for the new function.
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Community Treasure Hunt

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

Start Hunting!