MATLAB: Fast calculation of min for a cell array

cell arrayminimum

Hi, I have this cell array:
A =
3×160 cell array
Columns 1 through 5
{18×10754 double} {18×10754 double} {18×10754 double} {18×10754 double} {18×10754 double}
{31×14797 double} {31×14797 double} {31×14797 double} {31×14797 double} {31×14797 double}
{65×34310 double} {65×34310 double} {65×34310 double} {65×34310 double} {65×34310 double}
and for each of my 160 cells in A(3,:) (i.e. the 160 cells in the third row of A):
A(3,:) =
1×160 cell array
Columns 1 through 5
{65×34310 double} {65×34310 double} {65×34310 double} {65×34310 double} {65×34310 double}
I would need a very fast way to get the min of each column, and therefore such a cell array:
Amin =
1×160 cell array
Columns 1 through 5
{1×34310 double} {1×34310 double} {1×34310 double} {1×34310 double} {1×34310 double}
My attempt is the following:
t1 = tic();
for i = 1 : size(A(3,:),2)
[A_min_value, A_min_row] = min(A{3,i,:},[],1); % (min each column)
Amin_value{3,i,:} = A_min_value;
Amin_row{3,i,:} = A_min_row;
end
dt = toc(t1)
tic-toc time
dt = 0.129487033
Any faster way?

Best Answer

nc = size(A,2);
Amin_value = cell(1,nc);
Amin_row = cell(1,nc);
for k = 1:nc
[Amin_value{1,k},Amin_row{1,k}] = min(A{3,k},[],1);
end