Working with even rows
显示 更早的评论
Hello, I have a matrix 4x4, and I want to find the maximum of all elements which are in even rows.
采纳的回答
更多回答(1 个)
Wayne King
2012-4-16
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(:))
类别
在 帮助中心 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!