Select specific values inside a cell

1 次查看(过去 30 天)
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?

采纳的回答

OCDER
OCDER 2018-9-12
%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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Types 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by