MATLAB Answers

Why does NextTimeHit always return 0 in Matlab S-Functions?

5 views (last 30 days)
retigi
retigi on 3 Jul 2018
Answered: Archit Dhanani on 25 Jul 2019
I need to compute the step size (i.e. dt) in the discrete update method of a Matlab S-Function whose Sample Time is set to be "Inherited" (i.e. [-1 0]). However, regardless of the Sample Time specification (e.g. Inherited, Continuous, Discrete, Variable), the "block.NextTimeHit" always return "0" even though it is decleared as R/W in its Matlab Documentation.
  1. Why does NextTimeHit always return 0 in Matlab S-Functions?
  2. How can I infer the actual step size in update method of (Discrete) Matlab S-Functions for inherited and variable sample times?

  0 Comments

Sign in to comment.

Accepted Answer

Archit Dhanani
Archit Dhanani on 25 Jul 2019
the NextTimeHit is the API used specifically for variable discrete rates. You can read more about it in the page:
To get the actual step size used in the update method, you will have to use Dwork vectors. The link below demonstrates an example for using Dwork vectors:

  0 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Products


Release

R2017b