MATLAB: Select specific values inside a cell arraycellvalues Hi, I have a cell array that is 4×6. Inside each cell I have 1×31 values. I would like to access in each cell just the last value. At the end I want a matrix that is 4×6. Could you please help me with it? Best Answer %Just making a demo cell arrayA = cell(4,6);for j = 1:numel(A) A{j} = randi(100, 1, 31);end%Use for small sizes like 4x6 cell arrayC = cellfun(@(x) x(end), A);%Use for large sizes like 100x600 cell arrayB = zeros(size(A));for j = 1:numel(A) B(j) = A{j}(end);end Related SolutionsMATLAB: Manipulation of a cell array- Cell_array = {1,[],magic(2);'stirng',[],[]}cellfun('isempty',Cell_array) MATLAB: How to remove the duplicate in the cell array but still keep the array structure A = {[3 11];[6 5 8];[ 11 5];[5]};for iA = 1:numel(A) a = A{iA}; for jA = iA + 1:numel(A) A{jA} = A{jA}(~ismember(A{jA}, a)); endendOr:list = A{1};for iA = 2:numel(A) A{iA} = A{iA}(~ismember(A{iA}, list)); list = union(list, A{iA})end Related QuestionDelete empty [] {1×7 cell} {1×2 cell}How to unnest cell arrays using a for loopTransposing cellsCombine a cell array of cell arrays to a single cell arrayI need some help on matrix operations!
Best Answer