This guide is helpful for MATLAB users who are unaware of the method to find maximum and minimum values of the large data set and matrix in MATLAB.
How to Find the Min and Max Values in the Large Data Set and Matrix in MATLAB?
Finding the maximum and minimum values in a large data set can be easily done using the max() and min() functions. However, we have to use them separately. The bounds() function in MATLAB is a more efficient way to find the minimum and maximum values of a large data set or matrix. It is the built-in function in MATLAB that takes the matrix as an input and returns the maximum and minimum values of large data sets or matrices in MATLAB.
Syntax
The bounds() function uses a simple syntax in MATLAB:
[minA,maxA] = bounds(A,"all")
[minA,maxA] = bounds(A,dim)
Here,
The function [minA,maxA] = bounds(A) yield to obtain the minimum value minA and maximum value maxA of the given matrix or array A. Where minA equals min(A) and maxA equals max(A).
The function [minA,maxA] = bounds(A,” all”) yields to identify the minimum value minA as well as maximum value maxA over all entries of the given matrix or array A.
The function [minA,maxA] = bounds(A, dim) yield to identify the minimum and maximum values of each row of the given array A along the dimension dim.
Examples
Follow the given examples to learn how to compute the maximum and minimum values of the given matrix or data set using the bounds() function.
Example 1: How to Find the Min and Max Values of a 1D array in MATLAB?
In this example, we compute the maximum and minimum values of the given 1D array of random numbers having size 1-by-1000 using the bounds() function.
[min_vect, max_vect] = bounds(vect)
Example 2: How to Find the Max and Min Values of a Large Matrix in MATLAB?
This MATLAB code uses the bounds() function to identify the minimum and maximum values of the given large matrix having a size of 1000-by-1000.
[min_A, max_A] = bounds(A,"all")
Example 3: How to Find the Max and Min Values of a Large Array in MATLAB?
The given MATLAB code uses the bounds() function to compute the minimum and maximum values of the given array having a size of 2-by-10-by-2.
[min_A, max_A] = bounds(A,2)
Conclusion
Finding the minimum and maximum values of a large data set or matrix is a common problem faced by data analysts. This becomes easy by using MATLAB’s built-in bounds() function that computes the minimum and maximum values of the given array or matrix. This guide has provided the basics of using the bounds() function in MATLAB to find the minimum and maximum values in a large dataset. The examples provided here will allow you to quickly learn the use of the bounds() function in MATLAB.