MATLAB: Cell Array min excluding zero

cell arrayminimum

Hi, I want to find a min value that is not 0 from a cell array that has different number of elements in it:
cost = [1*11 double]; [1*12 double]; [1*7 double] and so on
at the moment I am finding the min like this:
[M,I] = min([cost_hist{:}]);
and I tried different variations with ~= 0 with no success. The index is also important.
Thanks in advance, Asher

Best Answer

C = {[0 10 0 2 4] [4 3 8] [0 5 -2 15] [2 6]};
minValue = Inf;
minIndex = 0;
for k = 1:numel(C)
Elements = C{k}(C{k} ~= 0);
aMin = min(Elements);
if aMin < minValue
minValue = aMin;
minIndex = k;
end
end
disp(minValue)
disp(minIndex)