How to save a structure array to a text file

arrays, matlab, structure, text-files

Solution

I know this thread is old but I hope it's still going to help someone:

I think this is an shorter solution (with the constraint that each struct field can contain scalar,arrays or strings):

%assume that your struct array is named data
temp_table = struct2table(data);
writetable(temp_table,'data.csv')

Now your struct array is stored in the data.csv file. The column names are the field names of a struct and the rows are the different single-structs of your struct-array

Problem

In MATLAB how do I save a structure array to a text file so that it displays everything the structure array shows in the command window?

Original source