File Exchange

image thumbnail

Bound Values of an array

version 1.0.0.0 (2.05 KB) by Pramit Biswas
Check whether value of the array within specified range or not and change accordingly

14 Downloads

Updated 29 Aug 2013

View License

Check whether value of the array within specified range or not, if in range it stays there as it is and if not then substitute by boundary value (depending upon which it breaks, if higher boundary breaks then replaced by higher boundary value and vice-versa)

function [ A2comp ] = MinMaxCheck( minimum, maximum, A2comp )
A2comp is the array to check
minimum and maximum are arrays which holds the minimum and maximum value of each element of an array (A2comp) respectively
output returns the array where all values within the range
if element of A2comp is less than minimum boundary value then it's changed to minimum boundary value
if element of A2comp is greater than maximum boundary value then it's changed to maximum boundary value
all array must be same in length

Cite As

Pramit Biswas (2020). Bound Values of an array (https://www.mathworks.com/matlabcentral/fileexchange/43251-bound-values-of-an-array), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (5)

Cris Luengo

This is terrible code: there is no need for loops, and you should never, ever, use "size" as a variable name, it is a most important function that you overwrite. Furthermore, it should say "size=length(minimum(:))", not "size=length(minimum)".

我也是出现这个错误

mgnt00

when i execute the code.. an error shows up "Missing input parameter(s)!"
Can someone help me please?!!

Johnie90

MATLAB Release Compatibility
Created with R2013a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired: BoundNDArray(array,lb,ub)