Fix a bug in matlab version