how to find the row wise maximum and minimum values of equal sized matrices in a cell array

2 次查看(过去 30 天)
Hi, I have a cell array containing 2 equal sized matrices a=[1 2 3;3 4 5]; b=[5 4 6;7 6 9]; c={a,b}; now i need to find the maximum and minimum values among both matrices a and b row wise using cell array operations. example : max(a(1,:) and b(1,:))=6 max(a(2,:) and b(2,:))=9 min(a(1,:) and b(1,:))=1 min(a(2,:) and b(2,:))=3 I know how to do with matrix operations by matrix concatenation. But how to do this using cell array operations without writing many lines of code.

采纳的回答

Guillaume
Guillaume 2017-2-3
Concatenate the matrices horizontally, get the max or min of this along the rows:
a=[1 2 3;3 4 5]; b=[5 4 6;7 6 9]; c={a,b};
max([c{:}], [], 2) %concatenation + max on rows
min([c{:}], [], 2) %concatenation + min on rows

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by