필터 지우기
필터 지우기

How to export .mat file to excel different sheets

조회 수: 31 (최근 30일)
TESFALEM ALDADA
TESFALEM ALDADA 2021년 12월 8일
편집: Mathieu NOE 2021년 12월 8일
Hello Everyone
I have a matlab file to be saved to excel but in 100 different sheets.
The example file i create here:
MAT = rand(10,100);
xlswrite('sampleData.xlsx', MAT) % this one saves all 100 column values to sampleData file
% but my idea is to save individual column values in the same excel file
% but in 100 different sheet.
Then how can i apply a loop to do so?,
Thank you.

채택된 답변

Mathieu NOE
Mathieu NOE 2021년 12월 8일
편집: Mathieu NOE 2021년 12월 8일
hello
yes , like this :
MAT = rand(10,100);
[m,n] = size(MAT);
for ci = 1:n
xlswrite('sampleData.xlsx', MAT(:,ci),ci) % xlswrite(file,data,sheet,range)
end

추가 답변 (1개)

Net Fre
Net Fre 2021년 12월 8일
In the function xlswrite you can specify the sheet you want to write into:
xlswrite(filename,A,sheet)
Then you can loop over the columns and write each one to a different sheet:
for i = 1:size(MAT,2) % i goes from 1 to number of columns
xlswrite('sampleData.xlsx', MAT(:,i),i) % write column i to the i'th sheet
end

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by