To find the maximum value of a matrix in MATLAB, you can use the max
function. The max
function returns the maximum value along a specified direction or in the entire matrix.
Here is an example:
main.m153 chars8 lines
Output:
main.m2 chars2 lines
In the above example, matrix(:)
converts the matrix into a column vector, and max
function is used to find the maximum value in the column vector.
You can also find the maximum value along a specific dimension of a matrix using the max
function. For example, to find the maximum value of each column, you can specify the second dimension as the direction:
main.m92 chars5 lines
Output:
main.m6 chars4 lines
In the above example, max(matrix, [], 2)
returns the maximum value of each column, and disp
function is used to display the results.
gistlibby LogSnag