Select specific values inside a cell

1 回表示 (過去 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 Center および File ExchangeData Types についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by