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.
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Array Geometries and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!