MATLAB: Find cell with nearest value cell arraysMATLABnearest I have cell array 1×406 which each cell has a value. And I want to find a cell with the value nearest to 0. In this case i want output is 175. Thank you Best Answer C = [yourcell{:}]; % assuming each cell contains a scalar[Value,Where] = min(C(C>0 & C<1)) Related SolutionsMATLAB: Assigning an empty numeric value to a cell array >>c = {[]};>>class(c{1})ans = double>>isempty(c{1})ans = 1Or if you really want to be specific:c = {double.empty(0)}; MATLAB: Nearest value but bigger nearest k = bsxfun(@minus,A(:)',B(:)); k(k >= 0) = -inf;[~,ii] = max(k);ii(all(k == -inf)) = 0; Related QuestionManipulation of a cell array-Finding nearest vlaue
Best Answer