Azzera filtri
Azzera filtri

Export Structure to csv file

545 visualizzazioni (ultimi 30 giorni)
Kathrin Sadus
Kathrin Sadus il 29 Set 2020
Risposto: Mohammad il 2 Mar 2022
Hi everyone,
I'm trying to export my data which is saved in a structure to a csv file. The structure is two dimensional but contains vectors in some cells. So far I tried to convert it in a table and save it using writetable, but the vectors were not recorded correctly.
Thanks for any advice,
Kathrin
  2 Commenti
Turlough Hughes
Turlough Hughes il 29 Set 2020
Can you attach the structure to the question?
Kathrin Sadus
Kathrin Sadus il 29 Set 2020
Sure! It looks like this one here.

Accedi per commentare.

Risposta accettata

Ameer Hamza
Ameer Hamza il 30 Set 2020
MATLAB just introduced writestruct(): https://www.mathworks.com/help/matlab/ref/writestruct.html in R2020b. If you have R2020b, you can directly write the struct in a text file.

Più risposte (2)

Sudhakar Shinde
Sudhakar Shinde il 29 Set 2020
You can try this:
load Structure_Example.mat
writetable(struct2table(PracTrials), 'Structure_Example.csv')
The output csv file snal looks as below:
  5 Commenti
Kathrin Sadus
Kathrin Sadus il 21 Ott 2020
Thank you very much for your help!
Aneesha
Aneesha il 3 Dic 2021
can you show the format of PracTrails

Accedi per commentare.


Mohammad
Mohammad il 2 Mar 2022
Hi,
I tried to used the same method to convert my struct mat file (attached) but failed. Any help is appreciated.

Categorie

Scopri di più su Cell Arrays in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by