Save dataset of struct with different kind of fields to Excel

3 Ansichten (letzte 30 Tage)
L Maas
L Maas am 28 Aug. 2019
Kommentiert: L Maas am 30 Aug. 2019
Hello,
I would like to save my Matlab data results, which is a 1 x 35 (35 participants) with 11 fields (11 outcome parameters) dataset.
I tried to use writetable(struct2table(DATA), 'DATA.xlsx') and it does save ALL the data, but is it not well organized anymore. It would be easiest to have all the parameters, which are fields with single values, doubles and structs, PER participant.
Moreover, writetable creates a kind of excelfile but I can not open it with Microsoft Excel, it only opens within Matlab, which is not useful for me.
Any suggestion on how to save all this data per participant, instead of copy paste it...?
Thank you in advance.
  2 Kommentare
Bob Thompson
Bob Thompson am 28 Aug. 2019
It seems like you have some visually complicated data structures. If you want to write them into an excel file you will need to determine how you want to take all of your arrays and structures and put them into 2D arrays with single elements per excel cell.
My best suggestion I can offer, until you know exactly how you want to expand the entire database, is to pick one collection of data (a single numeric array, or a single structure that doesn't contain other arrays) and decide how you want to present it. In my experience, a complex dataset usually needs to be handled piecemeal anyway, so learning how to deal with each small piece is not a wasted topic.
It is possible to automate the whole process, but because of the complexity of what you have shown in the image, and the visual simplicity of an excel sheet, it will be several small steps repeated, instead of a single command to dump the entire thing.
L Maas
L Maas am 30 Aug. 2019
I understand that it will take several steps to have the entire dataset 'copied' to excel in an organized way.
It is good to think about the way of organizing the data in Excel first. I will do that.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
Walter Roberson am 28 Aug. 2019
You cannot do that in Excel. Excel cells are scalars (or at most character vectors) and can never hold arrays or structs .
writetable() will replace all of the struct with empty entries, and will split all of those arrays into independent variables named after the linear index into the array.
Note: I had no difficulty openning the result of writetable() in Excel for Mac 2010.
  1 Kommentar
L Maas
L Maas am 30 Aug. 2019
I can now open the Excel file as well, so fortunately that is solved.
Okay, I understand that it is not possible to 'copy' the data set as how it is represented in Matlab, into Excel. writetable(t) save the entire dataset, but not in a useful way.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by