Filter löschen
Filter löschen

How can I export fields from a series of .mat struct files into seperate .csv files in a loop while maintaining the field names as the new file names?

5 Ansichten (letzte 30 Tage)
I have a bunch of struct files inside a folder. The only files present in the folder are the .mat struct files. Each .mat file is a 1x1 struct with 8 fields, and each field is a M x 5 double (M is constant inside the same struct, varying only between struct files). Both the .mat files and the fields are named according to a code for future reference (for simplicity and confidentiality, lets say the .mat files are named like APA1470fG; APA2470fG; APA3480fG (...) and the fields are named like APA4701hJ; APA4702hJ; APA480kJ (...). I need to export each field as a separate .csv file for analysis, but I wanted to create a loop so that I wouldn't have to export each and every single one manually, as there are simply too many fields in total that need to be exported, but I also need to be careful about the file names. Just to note that the actual names for both the struct and fields are very complex, so I don't see a way to load or save files using a logical naming approach in order to keep the existing names.
So, what I wanted to make was a loop that goes as follows:
  • Load each struct from the main folder at a time;
  • Create a folder inside the main folder with the same name as the .mat struct file;
  • Save each field as a .csv file with the same name as the field and save it on the created folder.
I would deeply appreciate if anyone could help me with my problem.

Antworten (0)


Mehr zu Structures finden Sie in Help Center und File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by