You can, of course, write your own statistics routines, but that is a job better left to experts. Here are links to free statistics toolboxes for MATLAB. Although these toolboxes have not been updated in several years, the core functions should not change as MATLAB is upgraded.
Gordon Smyth maintains the StatSci portal, which includes a good list of MATLAB Resources including the Statbox toolbox
You can download MATLAB functions developed for educational purposes from a separate directory.