MATLAB: Sort elements of cell array cell arrays hey i have a question that how to sort elements of cell array at once Like: x{1,1}={2;1;3} x{2,1}={4,2;1;3} and result should be like this: x{1,1}={1;2;3}; x{2,1}={1,2;3;4} Best Answer x{1,1}=[2;1;3] ;x{2,1}=[4;2;1;3] ;iwant = cellfun(@sort,x,'un',0) Related SolutionsMATLAB: Length of cells within cell array x{1,1}{1,1} = 1;x{1,1}{2,1} = [2;3;4];x{2,1}{1,1} = [3;1];x{2,1}{3,1} = [1;5;2;4];The trivial answer:length(x{1,1}{1,1})length(x{2,1}{3,1})To get all lengths at once:Len = cellfun(@(c) cellfun('length', c), x, 'UniformOutput', false)Now Len{2}(3) is 4. MATLAB: QUestion regarding Number of elements in a cell cellfun(@numel, X) Related QuestionRemoving cells from a cell array that contain certain values for a particular elementSortingTake lines from arraySorting
Best Answer