Working with even rows
Ältere Kommentare anzeigen
Hello, I have a matrix 4x4, and I want to find the maximum of all elements which are in even rows.
Akzeptierte Antwort
Weitere Antworten (1)
Wayne King
am 16 Apr. 2012
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 Kommentar
Polina Deneva
am 16 Apr. 2012
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!