return a maximum value of a table in matlab

You can use the max function in MATLAB to return the maximum value in a table. If your table is a matrix, you can use the function on the whole matrix as follows:

main.m
A = [1 2 3; 4 5 6; 7 8 9];
max_val = max(A(:));
48 chars
3 lines

In this example, the (:) operator converts the matrix A into a column vector, which then is searched for the maximum value. Finally, the maximum value is stored in the max_val variable.

If your table is not a matrix, you can use the max function with appropriate arguments to search along specific dimensions of the table. The documentation for the max function has more information on this syntax.

related categories

gistlibby LogSnag