fixed some bugs in matlab codegen