Azzera filtri
Azzera filtri

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

2 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Guillaume
Guillaume il 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

Più risposte (0)

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by