MATLAB: Saving 3 dimensional single data in an Excel file

save 3 dimensional as 2 dimensional excel file

Hello all
I have three dimensional epoched data (EEG data, 32*300*14 single ( channels x time points x trials) and I need to save the data in an excel file. However based on the error I got using xlswrite function, it seems that Excel handles only two dimensional data. . How can I save this 3 dimentional data (as 2 dimential i suppose) in an excel file? .
Thank you very much
Zahra

Best Answer

xlswrite is only able to write data in a 2D format because it can only write to one sheet at a time. In order to write your 3D data you can either reshape the data into a large 2D array, or you can run a loop to save each sheet of your data to a sheet of the excel file.
% Credit to cyclist for this
C = permute(A,[1 3 2]);
C = reshape(C,[],size(A,2),1)
% Or the loop
for i = 1:size(A,3)
xlswrite('myexcelout.xlsx',A,i)
end
Related Question