saving 3 dimensional single data in an Excel file

9 次查看(过去 30 天)
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

采纳的回答

Bob Thompson
Bob Thompson 2019-2-28
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
  2 个评论
Elaheh
Elaheh 2019-3-1
Thank you so much for your reply. The excel file was created but there is an issue. My orignial data is EEG (32*300*14), 32 is the number of channels (the EEG cap electords) that I have. In the excel file, I need each channel to occupy one row so that I have the data for each channel in front of it. The resulted file is 448*330. I do not know how the data is arranged.
Bob Thompson
Bob Thompson 2019-3-1
32*14 = 448. The data is organized such that each former sheet has been moved to the tail end of the first page. Therefore, the first 32 rows are the first sheet, the second 32 rows (33 to 64) are the second sheet, and so on.
I do not know where the extra 30 columns came from.

请先登录,再进行评论。

更多回答(1 个)

Fangjun Jiang
Fangjun Jiang 2019-2-28
write each page to each sheet
for k=1:size(data,3)
xlswrite('Book1.xlsx',data(:,:,k),k)
end
This will run xlswrite() k times so it's not most efficient.

类别

Help CenterFile Exchange 中查找有关 EEG/MEG/ECoG 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by