MATLAB Answers

Is it possible to make the Rate Limiter block in Simulink a variable rate limiter?

54 views (last 30 days)
I have an application where I would like to have a variable rate limiter. Simulink currently has a Rate Limiter block in the Discontinuities library. This block limits the falling and rising rates of signals. I would like the flexibility of having two extra inputs to this block where the rising and falling slew rates are variables.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 3 Apr 2020
Edited: MathWorks Support Team on 3 Apr 2020
This feature has been implemented in Simulink 6.0 (R14) via the Rate Limiter Dynamic block. If you are using a previous version, read the following:
The ability to use the Rate Limiter block to allow variable rising and falling slew rates is not available in Simulink.
To work around this issue, try writing a MATLAB file S-function that uses the SET_PARAM command to change the rising and falling slew rates. For a sample model and MATLAB file S-function that illustrates how to change the parameter of one block using the output value of another, see the related solutions section at the bottom of this page.
For example, you may use a command such as
to set the rising slew rate to the first input value to your MATLAB file S-function and use the following code
to set the falling slew rate to the second input value.
NOTE: 'fullblockname' refers to the full name of the Rate Limiter block that you are trying to change.
You may also find the following URLs helpful:
Programmatic Modeling basics:
Block Parameters:
MATLAB file S-functions:
Keep in mind that MATLAB file S-functions cannot be used with Real-Time Workshop, only C-MEX S-functions. An additional limitation of using S-functions with Real-Time Workshop is that C-MEX S-functions cannot call any MATLAB functions. For other guidelines for writing S-functions for use with Real-Time Workshop, see the related solutions section at the bottom of this page.
For real time applications, write your own version of the block as a C-MEX S-function. You will then be able to compile your block for use in Real-Time Workshop. As a guideline, use the algorithms given in the documentation for the Rate Limiter block, found at the following URL:
'Rate Limiter'
If you already have installed the help documentation for your licensed product(s), you may access the same page locally by typing the following at the MATLAB prompt:
web([docroot '/toolbox/simulink/slref/ratelimiter.html'])
For more information about creating a C-MEX S-function, see Chapter 3 of the Writing S-functions User's Guide. A PDF version of this guide can be found at the following URL respectively:

  1 Comment

Thomas Becker
Thomas Becker on 5 Feb 2018
Is it correct, that any Simulink.Parameter objects with storage class "global" are eliminated during code generation, i.e. they are neither present in code nor in the a2l file? I.e. their values are inlined during code generation? Shouldn't this fact be stated in the documentation more clearly?

Sign in to comment.

More Answers (0)

Sign in to answer this question.