MATLAB: How to get the minor time in a MATLAB s-function

s-functionsimulink

Inside a Level-2 Matlab S-function, block.CurrentTime gives the value of the major time. How can we get the value of the minor time?

Best Answer

Actually, block.CurrentTime gives the value of the current time-step in the simulation (could be either major or minor). The block outputs and derivatives (and potentially, zero-crossings) methods are run in minor time-steps. So if you are querying block.CurrentTime in one of these functions, you should simply have to check block.IsMajorTimeStep to verify if you're in a major/minor time-step.