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

 채택된 답변

Sean de Wolski
Sean de Wolski 2012년 4월 16일

1 개 추천

X = magic(4);
max(X(2:2:end,:))

추가 답변 (1개)

Wayne King
Wayne King 2012년 4월 16일

1 개 추천

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

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

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by