how to find the row wise maximum and minimum values of equal sized matrices in a cell array
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Srinivas STP Srinivas STP
le 3 Fév 2017
Commenté : Srinivas STP Srinivas STP
le 3 Fév 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 commentaires
Réponse acceptée
Guillaume
le 3 Fév 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
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!