Simplicity
Simplicity

Reputation: 48916

Maximum value in a specific column of a matrix

Say we have a matrix with dimensions 10x2. How can I find that maximum value of the rows for column 1 only in matlab?

Thanks.

Upvotes: 1

Views: 6522

Answers (2)

Vadim Smolyakov
Vadim Smolyakov

Reputation: 1197

A = rand(10,2);       %10x2 matrix
Amax = max(A,[],1);   %max across rows
Amax(1)               %max of the 1st col

This is a more generic approach in a sense that it computes max across all rows first that can be useful for accessing multiple max elements.

Upvotes: 0

Alexey
Alexey

Reputation: 5978

A = rand(10,2);    % 10x2 matrix
max(A(:,1));       % max for column 1 of A

Upvotes: 3

Related Questions