MATLAB: How to set an upper and lower limit on a data set from a matrix

matrices

I need to set an upper and lower limit on the numbers in a data set that belongs to a matrix.
How would I go about doing this?

Best Answer

at_least = -5.1234; %for example

at_most = 308.42; %for example
new_matrix = min(max(YourMatrix, at_least), at_most);
Now new_matrix has had every value less than at_least replaced with at_least, and every value greater than at_most replaced with at_most.
Related Question