Can matlab save a structure to an excel file so that each individual field is saved to one excel sheet?
    7 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    Zeynab Mousavikhamene
      
 am 26 Mai 2020
  
    
    
    
    
    Beantwortet: Sai Sri Pathuri
    
 am 29 Mai 2020
            Lets assume I have structure "struct" with fields: A, B, C and each field is a matlab table. I want to save this structure in one excel file so that each field is saved in one excel sheet like strucut.A is saved to sheet one, struct.B to sheet two and so on with the name of excel sheet being the name of that table. Becaue the number of fields are changing, I do NOT want to do this separately. I am seeking a way to do it all in once (to add the name of struct and matlab does the job).
0 Kommentare
Akzeptierte Antwort
  Sai Sri Pathuri
    
 am 29 Mai 2020
        You may use the following code
% Let the name of structure be s
f = fields(s) % get the fields of the structure
for i = 1:n % n is the number of fields in structure
    writetable(s.(f{i}),'Example.xlsx','Sheet',i)
end
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
				Mehr zu Spreadsheets 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!

