This problem occurs when an integrator is present in the model.
Open Configuration Parameter, set the diagnostic "Inf or NaN block output" to error, you will get the error as follows:
An error occurred while running the simulation and the simulation was terminated
- Block 'BlockName' outputs 'NaN' for element x of output port x at major time step 0
where BlockName is the block in which error is thrown.
This blocks has a divide by zero, which creates a Inf that when fed to an Integrator, generates this error.
So, avoid division by zero in the logic.