extracting columns from arrays within a cell

3 ビュー (過去 30 日間)
HC98
HC98 2021 年 12 月 7 日
回答済み: KSSV 2021 年 12 月 7 日
I have a cell consisting of 8 2x1 arrays and I want to extract the second column from them all. Usually, i'd use
k = cell2mat(data)
data1 = k(:,1:2:end);
But that doesn't work. How do I do this with cells?

回答 (1 件)

KSSV
KSSV 2021 年 12 月 7 日
% Demo data
A = cell(8,1) ;
for i = 1:8
A{i} = rand(2,1);
end
data = cell2mat(A')' ;
data(:,2)
ans = 8×1
0.2973 0.4424 0.1429 0.6127 0.5351 0.1065 0.5628 0.9994

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

タグ

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by