maximum(A,dims)
maximum(A, dims)
Compute the maximum value of an array over the given dimensions.
Examples
-
Find the maximum value in an array:
julia> arr = [5, 10, 2, 8, 3]; julia> maximum(arr) 10
This example finds the largest element in the array
arr
. -
Find the maximum value in a range of numbers:
julia> maximum(1:10) 10
It returns the maximum value in the range of numbers from 1 to 10.
- Find the maximum value in a vector of strings:
julia> words = ["apple", "banana", "orange", "grape"]; julia> maximum(words) "orange"
It returns the string with the highest lexicographic order from the vector
words
.
Common mistake example:
julia> maximum([])
ERROR: ArgumentError: collection must be non-empty
In this example, an empty collection is passed to maximum
, which raises an ArgumentError
. Ensure that the collection passed as an argument is non-empty to avoid this error.
See Also
Array, broadcast, cat, combinations, conj!, digits!, fieldnames, fill, fill!, last, length, maximum, minimum, ones, parent, parentindexes, partitions, permutations, pointer, pointer_to_array, promote_shape, rand!, reshape, scale, similar, sum, sum_kbn, takebuf_array, transpose!, vec, zeros,User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.