MATLAB: Convert struct with several fields into long table


I have a structure (see image) with 9 fields and 100 rows. Each row is a 200×1 double. As each row has exactly the same dimensions, I was wondering if there was a function I could use to open up the rows to make a long table with 20000 rows?

Best Answer

  • Try this
    T = array2table(cell2mat(squeeze(struct2cell(trai)).'), 'VariableNames', fieldnames(trai))