.mat to .excel

조회 수: 6 (최근 30일)
Kiara Xhindi
Kiara Xhindi 2021년 5월 31일
답변: Walter Roberson 2021년 6월 1일
Hello I was using this workflow to convert the .mat file to excel file
load('Filename.mat')
csvwrite ('NewfileX.csv', File00X);
So my initial matrix is composed of 90 matrixes and I was wondering how to automate this process so that the loop does each matrix one by one. I was trying to make the X value change each loop but it doesn't work.

답변 (1개)

Walter Roberson
Walter Roberson 2021년 6월 1일
filestruct = load('filename.mat');
fields = fieldnames(filestruct);
for K = 1 : length(fields)
thisfield = fields{K};
outfilename = sprintf('New_%s.csv', thisfield);
csvwrite(outfilename), filestruct.(thisfield));
end
This will write each variable inside of filename.mat as a separate csv file that is named "New_" followed by the name of the variable.

카테고리

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