Read c3d-files into Matlab
Show older comments
I have two directories of data: 'data_stair_rise' and 'data_sts'. Each directory contains 5 subfolders: 'pp1', 'pp2', 'pp3', 'pp4' en 'pp5'. Each subfolder contains some '.c3d-files'. (see attachment).
We need to read these files into Matlab. The teacher gave us a function who can read these c3d-files, but we need to create 5x5 struct (5 subjects x 5 measurements). (see attachment).
I don't have ANY idea how to start... Please help.
2 Comments
Suad Abu Shaar
on 24 May 2023
Can you share the command used to read the c3d file please
Image Analyst
on 24 May 2023
@Suad Abu Shaar, @Sam had a function he called "read_c3d_file" but he never attached it. And since it's 9 years later, I doubt he ever will.
Answers (2)
Image Analyst
on 24 Dec 2014
0 votes
I don't know what's in the file. In a single .c3d file, how many subjects, and how many measurements are in it?
When you use your teacher's function, what kind of variable does the file get read in to? A single structure? An array of structures? We have no idea, but you should since you and your teacher have the code.
8 Comments
Sam
on 25 Dec 2014
Image Analyst
on 25 Dec 2014
If you have questions still after reading the FAQ, come back and ask. http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
Sam
on 25 Dec 2014
Image Analyst
on 25 Dec 2014
I'm not sure how a 5x5 struct array holds 6 things. But you can just dynamically create indexes and fields, like
for col = 1 : 5
for row = 1 : 5
sa(row, col).field1 = thing1; % Whatever this is.
sa(row, col).field2 = thing2; % Whatever this is.
sa(row, col).field3 = thing3; % Whatever this is.
sa(row, col).field4 = thing4; % Whatever this is.
sa(row, col).field5 = thing5; % Whatever this is.
sa(row, col).field6 = thing6; % Whatever this is.
end
end
You can call the fields whatever you want and somehow read the 6 "things" from your data file before assigning them to the structure array, sa. I don't really know what rows and columns represent but I guess you will. Add a third index to sa if you need to, to represent the four cd3 files for each subject.
Sam
on 25 Dec 2014
Image Analyst
on 25 Dec 2014
First of all, let's not call it a cell since it's not. That's an entirely different animal One element of a structure array is a structure, not a cell.
In your loop, the values like VideoSignals are not changing. Why not? Well it's because they're always the same since there were assigned before the loop. If you want different ones, then you have to call read_c3d_file() INSIDE THE LOOP, not prior to it. Don't you understand that if you call read_c3d_file() before then those values will be the same no matter how many times you iterate a loop? Why should they change? They won't , unless you update them with a call to read_c3d_file().
Walter Roberson
on 24 May 2023
0 votes
see https://www.mathworks.com/matlabcentral/fileexchange/69372-ezc3d
and tools listed at https://www.c3d.org/c3dapps.html
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!