how to retrieve a table from a cell array?

23 ビュー (過去 30 日間)
MA
MA 2021 年 9 月 20 日
コメント済み: MA 2021 年 9 月 20 日
In the following hierarchy structure of the cell array 'results', assuming that this is a huge set of data tables where we don't know where the table we want for a specific date is located. How can I retrive a certain table from the cell array 'results' that is shown below, using the values in the first column (data file name) of 'results' and the value of the 'Date' variable in the desired table? any idea...
for example:
the cell array results would look like this:
and when expanding a cell from the second column it would look like the image below, where these are the tables that I would like to retrive based on the 'Date' variable (8th column) inside them
and the tables are having the following formats
  2 件のコメント
Stephen23
Stephen23 2021 年 9 月 20 日
編集済み: Stephen23 2021 年 9 月 20 日
In general, keeping data together makes it easier to work with.
Although you have spent considerable effort splitting your data up into lots of separate tables, that rather defeats the purpose of using tables (which ultimately is to efficiently group and process data within one array). Most likely this task would be simpler if you just had one table, not hundreds of tables nested in a cell array.
MA
MA 2021 年 9 月 20 日
thanks for your commnet, I agree with you, but this is for the purpose of sorting some data out and it will later on be applied to a huge number of data files. there might be a better way of implementing such thing for sure, but I am a begginer here and I am trying to learn.

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

採用された回答

Kevin Holly
Kevin Holly 2021 年 9 月 20 日
The answer is actually written on your tabs.
To view the whole table in the last screenshot, type the following:
results{1,2}{1}
  8 件のコメント
Kevin Holly
Kevin Holly 2021 年 9 月 20 日
Alternatively, you could try this if your Date is in datetime format within your table:
Array_of_Tables(i,:) = any(ismember(str2num(char(results{1,2}{i}.Date)),196612010520))
MA
MA 2021 年 9 月 20 日
Both of them worked peerfectly as needed. Thank you for your time and your effort.

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

その他の回答 (1 件)

Sargondjani
Sargondjani 2021 年 9 月 20 日
NEver used table but i think this will work:
X = results{1,2}{1,1};
MyDates = X.Date;
Might even work directly:
MyDates = results{1,2}{1,1}.Date
  2 件のコメント
MA
MA 2021 年 9 月 20 日
thank you for your reply, but the aim is to retrieve the whole table given a specific Date value, not the Date values. and assuming that this is a huge set of data where we don't know where the table we want for a specific date is located.
Sargondjani
Sargondjani 2021 年 9 月 20 日
In that case look at the function: find
Im sure there are many posts about "find a specific value in a matrix"

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

カテゴリ

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

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by