Train Cascade Object Detector example in MATLAB
You are not doing anything wrong.  This particular example is there for a quick illustration, and it does not produce a very good detector. It trains a 5-stage detector from a very small training set.  A decent detector may have 20 stages or more, and you would need thousands of positive samples and negative images to train it.

Take a look at this tutorial for more information.