How to select the maximum value for each row in cell type variable in matlab?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Niraj Bal Tamang
am 27 Jan. 2021
Kommentiert: Jan
am 8 Feb. 2021
I have a cell type variable(Final) with dimension 279*100. I want to create a new matrix of 279*1 dimension such that i can have only the maximum value of each row in the new matrix. Can anyone please help me do this?
Thank You
0 Kommentare
Akzeptierte Antwort
Jan
am 27 Jan. 2021
Bearbeitet: Jan
am 27 Jan. 2021
Some rows of the cell Final contain only empty elements. What do you want to be the output in this case? If NaN is sufficient:
nRow = size(Final, 1);
FinalMax = nan(nRow, 1);
for k = 1:nRow
row = [Final{k, :}];
if ~isempty(row)
FinalMax(k) = max(row);
end
end
2 Kommentare
Jan
am 8 Feb. 2021
Of course. Simply change "FinalMax = nan(nRow, 1);" to "FinalMax = zeros(nRow, 1);
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!