How to restrict the range ?
Show older comments
I want to restrict the output of the arc cosine to be in the range [-1,1], but I want to know if there is built-in Matlab function for this task and if it is possible for example merge @max & @min simultaneoulsy in the function bsxfun to achieve this task.
Accepted Answer
More Answers (1)
Walter Roberson
on 3 Mar 2016
min(max(x, -1), 1)
2 Comments
Susan Arnold
on 3 Mar 2016
Edited: Susan Arnold
on 3 Mar 2016
Jos (10584)
on 4 Mar 2016
Simply replace -1 and 1 by the minimum and maximum of B
... max(A,min(B(:))) ...
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!