After struggling for one day, I found two main causes for my problem. The first one is that there was an algebraic loop in my model due to a missing setting in a S function, which made Simulink run the model MULTIPLE times in ONE time step to solve the algebraic loop. The second one is that the [Update Method] of my Matlab Function was set to be [inherited]. The problem disappeared after (1) removing the algebraic loop and (2) changing the [Update Method] to [discrete] and setting the [Sample Time] equal to the (fixed) step size of the model.
Hope this may help people who confront similar problems.