Clear Filters
Clear Filters

Find minimum of first column of matrix among multiple cells and then second and so on..

4 views (last 30 days)
M is a cell array of 1650x1 rows
M{1} is a matrix of 160x1 rows
Looking to find the minimum among each row of every matrix, different cell
Loop 1:
M{1}(1)
M{2}(1)
M{3}(1)
.
.
until
M{1650}(1)
(Find which is the minimum value)
Loop 160
M{1}(160)
M{2}(160)
M{3}(160)
.
.
until
M{1650}(160)
compare M{1}(1) and M{2}(1) and so on to see which is minimum

Accepted Answer

Guillaume
Guillaume on 13 Oct 2017
Edited: Guillaume on 13 Oct 2017
Since all the vectors are all the same size, why are they stored in a cell array. Simpler would be to convert that cell array to a matrix, which also makes the task of finding the minimum trivial:
M = [M{:}]; %convert to a matrix by concatenating all the column vectors together
min_val = min(M, [], 2) %get the minimum across the 1650 columns

More Answers (0)

Categories

Find more on Data Type Conversion 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!