implement output batch and output function of matlab