Clear Filters
Clear Filters

Select specific values inside a cell

5 views (last 30 days)
Auryn_ on 12 Sep 2018
Answered: OCDER on 12 Sep 2018
I have a cell array that is 4x6. Inside each cell I have 1x31 values.
I would like to access in each cell just the last value. At the end I want a matrix that is 4x6.
Could you please help me with it?

Accepted Answer

OCDER on 12 Sep 2018
%Just making a demo cell array
A = cell(4,6);
for j = 1:numel(A)
A{j} = randi(100, 1, 31);
%Use for small sizes like 4x6 cell array
C = cellfun(@(x) x(end), A);
%Use for large sizes like 100x600 cell array
B = zeros(size(A));
for j = 1:numel(A)
B(j) = A{j}(end);

More Answers (0)


Find more on Data Types in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!