how to retrieve a table from a cell array?
19 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MA
el 20 de Sept. de 2021
Comentada: MA
el 20 de Sept. de 2021
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/744329/image.png)
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/744334/image.png)
and the tables are having the following formats
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/744339/image.png)
2 comentarios
Stephen23
el 20 de Sept. de 2021
Editada: Stephen23
el 20 de Sept. de 2021
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.
Respuesta aceptada
Kevin Holly
el 20 de Sept. de 2021
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 comentarios
Kevin Holly
el 20 de Sept. de 2021
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))
Más respuestas (1)
Sargondjani
el 20 de Sept. de 2021
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 comentarios
Sargondjani
el 20 de Sept. de 2021
In that case look at the function: find
Im sure there are many posts about "find a specific value in a matrix"
Ver también
Categorías
Más información sobre Timetables en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!