how to find the row wise maximum and minimum values of equal sized matrices in a cell array
2 views (last 30 days)
Show older comments
Srinivas STP Srinivas STP
on 3 Feb 2017
Commented: Srinivas STP Srinivas STP
on 3 Feb 2017
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.
0 Comments
Accepted Answer
Guillaume
on 3 Feb 2017
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
More Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!