Check for a certain variable in a cell filled with different timetables
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Pascal Viertel
il 6 Mag 2022
Risposto: Mitch Lautigar
il 6 Mag 2022
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 Commenti
Risposta accettata
Mitch Lautigar
il 6 Mag 2022
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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Array Geometries and Analysis in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!