필터 지우기
필터 지우기

Writing 3D array to excel sheet

조회 수: 41 (최근 30일)
Zee
Zee 2022년 6월 3일
편집: Dhanush Yeddula 2022년 6월 7일
Hello,
I would like to write Matlab output having dimension 2040x5x174 to an excel sheet. xlswrite function is restricted for 2D array as I get following error: 'Dimension of input array cannot be higher than two.'
Is there any other function that I can use or any other way to write this. Thanks.
  댓글 수: 1
Walter Roberson
Walter Roberson 2022년 6월 3일
Either reshape() or write the slices to separate sheets. Excel has no support for 3d arrays.

댓글을 달려면 로그인하십시오.

채택된 답변

Dhanush Yeddula
Dhanush Yeddula 2022년 6월 7일
편집: Dhanush Yeddula 2022년 6월 7일
The function “xlswrite can handle only 2D data. 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. The conversion from 3D to 2D can be done in a couple of ways. The following examples demonstrate these techniques:
%% Example 1
a = rand(3,3,3)
for i = 1:3
% use a for loop to remove 1 dimension and write into different worksheets
b = (squeeze(a(i,:,:)))'
xlswrite('exanple1.xls', b, ['Sheet', num2str(i)])
end
%% Example 2
a = rand(3,3,3)
% use reshape to remove 1 dimension
b = reshape(a,3,9)
xlswrite('example2.xls', b)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

제품


릴리스

R2011b

Community Treasure Hunt

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

Start Hunting!

Translated by