fix matlab function bug