필터 지우기
필터 지우기

Select specific values inside a cell

조회 수: 2 (최근 30일)
Auryn_
Auryn_ 2018년 9월 12일
답변: OCDER 2018년 9월 12일
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