update cost function example for MATLAB publishing.