Hello, I have a matrix 4x4, and I want to find the maximum of all elements which are in even rows.

 Respuesta aceptada

Más respuestas (1)

Wayne King
Wayne King el 16 de Abr. de 2012

1 voto

x = randn(4,4);
y = x(2:2:end,:);
max(y,[],2)
The above gives you maximums in rows 2 and 4.
If you want the maximum of all the elements in rows 2 or 4 considered all at once
x = randn(4,4);
y = x(2:2:end,:);
max(y(:))

1 comentario

Polina Deneva
Polina Deneva el 16 de Abr. de 2012
all at once - I did it (sorry for the bad english...) and this will also work on a bigger matrice, right?

Iniciar sesión para comentar.

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by