To use one of the functions described below, download the zip-file and extract the .c, .mexw32/mexw64 and the .mdl file. Save the files in your model directory, such that Matlab and Simulink Coder are able to find them. To include the function in your own model, open the .mdl file and use copy/paste.
Note that these functions only work on Matlab platforms supporting mex files.
More specifically the extension mexw32 is for 32-bit Matlab versions starting from 7.5(R2007b) for Microsoft Windows.
The mexw64 is for the 64-bit Matlab versions for Microsoft Windows.
To use these files, you need to have the Microsoft Visual Studio 2010 run-time libraries to be installed on your computer.
On other platforms, you need to compile the C source yourself.
Generates a staircase reference signal.
- Number of steps
- Increment for every step
- Time for every step
- Direction: When 0, the output will go down to zero, otherwise the output goes up to the specified number of steps
- The generated signal, staircase-shaped
- Relative time: The time elapsed since the start of the staircase (this signals resets to zero when the staircase reaches its final value)
Number of steps = 10 Increment per step = 10 Time for every step = 0.2
The figures below show the input signal (in) and the two output signals (Out and RelTime)
Makes an input signal more smooth by generating a sigmoid (skew-sinus). As soon as the input signal changes, a new sigmoid is generated, starting at the old input value, ending in the new input value, over a duration of the specified setup-time.
- Setup time: This is the time it will take to make the output value equal to the current input value
- Reference value: As soon as this input changes, a new sigmoid function is generated, starting at the old input value, ending in the new input value
- The generated signal, sigmoid-shaped
Setup time = 1
The figures below show the input signal (in) and the output signal (Out)
This function can generate a wide variety of reference signals.
- Setup time: This is the time it will take to make output value from the current value to the new desired value. When this parameter is zero, the specified maximum velocity and maximum acceleration are used to calculate the setup time.
- Setup function type:
- 0: Step
- 1: Ramp
- 2: Second order
- 3: Third order
- 4: Skew-sinus
- Maximum Acceleration: Only applies for second/third/skewsinus type functions.
- Maximum Velocity: Only applies for second/third/skewsinus type functions. This parameter is only used when the setup time is specified as 0 (i.e. when the trajectory-time is calculated online)
- ActualPos: When a new reference is started, it will start at this value
- DesiredPos: Desired end value of the refernce signal
- Start: This signal triggers the generation of the reference signal. When zero, the output will be equal to the 'ActualPos' input. Otherwise the reference trajectory is generated
- Position: This is the generated reference signal. When the 'Start' input is zero, this output will be equal to the 'current value' input.
- Velocity: Derivative of the reference position. When the 'Start' input is zero, this output will be 0.
- Acceleration: Derivative of the reference velocity. When the 'Start' input is zero, this output will be 0. This signal will also be zero if the acceleration is infinit.
- Ready: Indicates when the reference trajectory has finished.
Setup time = 0 Type = 4 (skew-sinus) MaxAcc = 5 MaxVel = 1
The inputs are selected as: ActualPos = 0.5 DesiredPos = -0.5
The figures below show the four output signals (Position, Velocity, Acceleration and Ready)
This function can generate a Pseudo-Random Binary Signal (PRBS), see e.g. the System Identification toolbox. The output is a maximum length PRBS with a periodicity of 218-1 (in Matlab see: help idinput).
- Discrete time step: This parameter specified at which rate output is generated.
- Mean value: The output is centered around this value.
- Amplitude: The output equals the mean value plus or minus this amplitude.
- The generated PRBS signal.
Discrete time step = 0.05, Mean value = 0, Amplitude = 4
The figure below shows the output signal.