If you have matlab 2015, then you should use that version.
If you do not, then I'm fairly certain that copying code from it is a violation of your license (i.e. it's illegal). Plus, as you found out it does not work.
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!