MATLAB: Saving a structure to Excel

excelnested structuresavestructure

I have a simple (albeit large) structure that follows the pattern Year.Variable.Month.TimeSlot
There are 8 TimeSlot values, and when opened each one displays a 16×1 array. I'm looking for something that will enable me to save all 8 of these values into excel (i.e. saving a single month of data). If there was a way to save each month onto the same Excel file, this would be great, however I don't mind a little manual cutting and pasting to put all the months together on a single sheet.
Any help would be massively appreciated.

Best Answer

Try this out (adapt it to your need)
a.b.c.d = rand(16,1);
a.b.c.e = rand(16,1);
my_last_field = fieldnames(a.b.c);
% write the last field values in a single matrix
L = numel(my_last_field);
my_data = zeros(16,L);
for k=1:L
my_data(:,k) = a.b.c.(my_last_field{k});
end
% write the matrix to excell sheet
xlswrite('text.xls',my_data)