isolate the row of a vector with the highest entry in column 3 in matlab

You can use the max function to find the maximum value in column 3 of the matrix and its row index, and then index the matrix using that row index to isolate that row. Here's an example:

main.m
% create a sample matrix
matrix = [1 3 5; 2 4 6; 3 1 2];

% find the row index of the maximum value in column 3
[~, max_row] = max(matrix(:, 3));

% isolate the row with the maximum value
max_row_vector = matrix(max_row, :);
225 chars
9 lines

In this example, max_row_vector will be [2 4 6], which is the row with the highest value in column 3.

related categories

gistlibby LogSnag