Matlab code example for piecewise linear approximation and Euler Equation Iteration
Two suggestions: 

First, try some of the sample code at this website. It builds simple Euler equation iteration methods from scratch in Matlab. 

Second, try the sample code here. You will need to read the associated notes, also. The code makes use of the CompEcon toolbox in Matlab, by Miranda and Fackler (associated with their book:  Applied Computational Economics and Finance).