An array / matrix of tables

234 ビュー (過去 30 日間)
Alon Osovsky
Alon Osovsky 2020 年 11 月 17 日
回答済み: Sai Veeramachaneni 2020 年 11 月 20 日
Hi! I want to load an unknown amount of tables, and store them in an array, list, or even a matrix.
I tried implomenting it using a simple array, and even a cell array (in which each cell represnets a table), but I always find myself getting errors like "Can't convert from table to cell".
Is there is a way to store multiple tables is some sort of a list?
Thanks in advance!
  2 件のコメント
Adam Danz
Adam Danz 2020 年 11 月 17 日
Show us what you tried so we can work out the kinks. A table can be stored in a cell array easily using
c{i} = T; % where T is a table
Peter Perkins
Peter Perkins 2020 年 11 月 19 日
You can't make an "array of tables" per se, because a table is already an array. But you can put multiple tables in a cell array, as Adam shows. Another option (if they are similar enough) is to vertcat them and add a variable that says which "chunk" of data each row is from. Things like groupsummary and varfun can work with a format like that, using the new variable as a "grouping variable".

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

回答 (1 件)

Sai Veeramachaneni
Sai Veeramachaneni 2020 年 11 月 20 日
Hi.
I think you are using smooth parenthesis for assigning table to cell index i.e. c(1)=Table which results in "Can't convert from table to cell".
Try changing parenthesis to curly braces i.e. c{1}=Table
For loading unknown amount of tables you can iterate over each table and assign them inside cell dynamically.

カテゴリ

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

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by