Matlab has built-in functions for finding the minimum and maximum values of an array or a list of values.
min
functionThe min
function finds the minimum value of an array or vector. Syntax:
main.m7 chars2 lines
where A
is the array or vector.
Example:
main.m28 chars3 lines
Output: 1
max
functionThe max
function finds the maximum value of an array or vector. Syntax:
main.m7 chars2 lines
where A
is the array or vector.
Example:
main.m28 chars3 lines
Output: 9
These functions can also be used with multiple input arguments to find the minimum or maximum value in comparison to the values of the rest of the inputs.
gistlibby LogSnag