Check for a certain variable in a cell filled with different timetables

3 次查看(过去 30 天)
Hello MathWorks Community.
I have a 6x1 cell which inherits 6 timetables with different sizes called "data".
The columns in these different timetables are all named unique in a way e.g. "var1" ... "varX" but shuffled randomly between the timetables.
If i know the correct timetable of var1, "data{1}.var1" gives me the according var1 data.
Right now i try to find the position/timetable of a specified variable. But how do i do that?
Thanks in advance.
P.S: Image illustrates the structure im working with.

采纳的回答

Mitch Lautigar
Mitch Lautigar 2022-5-6
What you need to do is to index through every timetable. Since data is a structure, you can use fields command to get all of the fields inside data, and then index through each timetable. This looks like the following.
field_names = string(fieldnames(data));
for i = 1:length(field_names)
curr_timetable = data.(field_names(I));
%input logic to handle timetables here
end
This will let you index through the starting array, and then it's a matter of looking at the variable names in the table. I believe the property you are looking for is "head" (source: https://www.mathworks.com/help/matlab/timetables.html )

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Array Geometries and Analysis 的更多信息

标签

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by