Change table of structs into columns of data in a table

7 次查看(过去 30 天)
I have many tables which contain anywhere from 2000 - 7500 1x1 structs in one column. Each struct contains a value for x, y and z positions. I need to extract these 3 numbers from each struct and have them in their own columns (as just regular floats). The end result will be a table with a column for x values, a column for y values, and a column for z values.
I've attached an example file (.mat).
What is an efficient way to do this?

采纳的回答

Mohammad Sami
Mohammad Sami 2020-9-8
Based on your example data this will work. All structs must have the exact same fields, otherwise this will fail
flattened = struct2table(vertcat(data{:,1}));
  1 个评论
Centauri Jolene
Centauri Jolene 2020-9-9
Thank you this worked perfectly. I just had to change it to
flattened = struct2table(vertcat(data.dog1_pos(:,1)));
since it wasnt a cell array. Cheers

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

产品


版本

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by