MATLAB: Pick up elements from a cell array and the result must be a cell array cell array I want to pick up all elements of a cell array except the last element. When I do V{1:end-1}, the result seems not to be a cell array. Best Answer With a cell array, {} operates on the content of the cells, () operates on the cell array itself.So, to crop a cell array:newcellarray = yourcellarray(1:end-1);Note that yourcellarray{indices}retuns a comma separated list of the content of the cells indexed by indices.edit: so a convoluted way of also cropping the cell array (as long as it is a row cell vector) would be:newcellarray = {yourcellarray{1:end-1}};which would unpack all the elements but the last into a comma-separated list and repack it into a new cell array. A bit convoluted! Related SolutionsMATLAB: Combine a cell array of cell arrays to a single cell array NewCellArray = vertcat( ExistingCellArray{:} ); MATLAB: Manipulation of a cell array- Cell_array = {1,[],magic(2);'stirng',[],[]}cellfun('isempty',Cell_array) Related QuestionCell array of nested cellsDelete empty [] {1×7 cell} {1×2 cell}Transposing cellsCell operationConvert an 18×1 cell array in a 3×6 cell array
Best Answer