Creating loop to extract column from table in a cell within a cell?

1 回表示 (過去 30 日間)
HC
HC 2018 年 6 月 25 日
編集済み: ans 2022 年 3 月 12 日
I have F (1x99 cell), within F, there are 99 tables with different numbers of rows, but 3 columns. I want to extract the 3rd column of each cell. Finally, creating a long vector. How would I create a loop that does this?
  4 件のコメント
Adam
Adam 2018 年 6 月 25 日
Do you mean actual tables or just numeric arrays?
HC
HC 2018 年 6 月 25 日
I meant tables, apologies.

サインインしてコメントする。

回答 (1 件)

Gayatri Menon
Gayatri Menon 2018 年 6 月 28 日
Hi,
Hope this example helps you get started. Suppose there is a cell array named cell_array which has 3 tables T1, T2 and T3 each with 3 columns - Name, Age, Weight. The following code snippet can be used to get the Weight column of all these tables and create a long vector "data":
cell_array={T1,T2,T3}
data=[];
for i=1:3
temp = cell_array{i}.Weight;
data=[data;temp]
end
Hope this helps.
Thanks
Gayatri
  1 件のコメント
ans
ans 2022 年 3 月 12 日
編集済み: ans 2022 年 3 月 12 日
Hello! It is really helpful for a cell array with 1x4 dimension. But for my case, I have a cell array of 1x24 that has 24 tables in it. I want to create a long vector for Weight column of each 4 tables using loops. At the end, I want to get six long vector for Weight column. Thanks!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by