Creating a function to Import data into structures
显示 更早的评论
Hello,
I am currently using an sdk to import data from a software we use in our lab. When I import the data, I bring it into matlab in structures arrays which have fields for each trial I import, and sub-fields for each marker. So the structure looks like this...
TrajX.trialname.marker_name (TrajX stands for trajectory in the x direction)
I wanted to write a function to import this data so as to down on the lines of code in the script. However I am running into an issue. When I define the output of my function to NOT include the trial name...
[TrajX] = Import_Data_Function(vicon,subject,trialname,firstframe,lastframe);
the data is imported just fine, but the first trial's data gets overwritten when I attempted to import the next trial's data. So I end up with only one field consisting of a single trial name
If I include the trial name in the output of my function...
[TrajX.(trialname)] = Import_Data_Function(vicon,subject,trialname,firstframe,lastframe);
the data is imported with a field for each trial name, but instead of a structure that consists of TrajX.trialname.marker_name, I get a structure that consists of TrajX.trialname.trialname.marker_name. Basically, there is a field for each trial name followed by another sub-field of the same trial name, then another sub-field for each marker name.
I'm not sure why this second method creates two fields/sub-fields for trial names when I only want one???
Any help on this would be greatly appreciated. I've attached the original script, function, and new script with function.
Thanks in advance.
2 个评论
Mathieu NOE
2023-3-15
hi
what is the way you want to have one or multiple files get organized in a data structure ?
Josh Tome
2023-3-16
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!