Select specific values inside a cell

1 vue (au cours des 30 derniers jours)
Auryn_
Auryn_ le 12 Sep 2018
Réponse apportée : OCDER le 12 Sep 2018
Hi,
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?

Réponse acceptée

OCDER
OCDER le 12 Sep 2018
%Just making a demo cell array
A = cell(4,6);
for j = 1:numel(A)
A{j} = randi(100, 1, 31);
end
%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);
end

Plus de réponses (0)

Catégories

En savoir plus sur Data Types dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by