I would like to write a Matlab code for an angular velocity of this type:


where $\omega_{fb}$ is a feedback angular velocity and $\omega_{ff}$ is a feedforward angular velocity.

As you can see, the feedforward term has been saturated.

The problem is that there is not a saturation function in Matlab. Moreover, I would like to do this inside a Matlab function block, and not use the saturation block of Simulink.

I have heard that some use the atan() function to perform the saturation, but I am not sure I can do this.

So, my question is:

How can I define the saturation function in Matlab?


1 Answer 1


You could always employ conditional expressions that are clear and explicit. Instead, if you like compact forms, you may implement saturation as below:

w = w_fb + min(hi, max(low, w_ff));

where hi and low are the upper and lower bounds of the saturation.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.