Copy results from a .mat file to existing excel file
6 ビュー (過去 30 日間)
古いコメントを表示
Hello, I have a .mat file (please check the attached script which produces it) as an output and I want to export the results into an existing excel sheet. Run1 and Run2 in the image are the results from previous simulations which are saved in .mat file everytime i run my script. I entered those 2 manually and I can't find a way to export by writing a script. The case names and number of outputs are same everytime, only the output changes. Thank you very much for your help. (Matlab version: R2018b)
2 件のコメント
Maximilian Panzik
2020 年 9 月 17 日
Hi there,
as I understand you need to continue an excel file, that is already populated.
So first you need to know, where to continue, so find out the size of the exising data:
[num,txt,raw] = xlsread(filename);
[rowN,colN] = size(raw);
You now have to define, where you start to write your data in the format 'A1'. If your max column is Z, you could use
range = [char(colN + 1 + 64),'1'];
Format your data in an array that equals your export format and use
xlswrite(filename,data,sheetName,range);
to write to your excel file.
採用された回答
Maximilian Panzik
2020 年 9 月 18 日
You can use struct2array
sz = size(testSetup,2);
arrSz = sz*4;
exportArr=[];
for i = 1:sz
str = struct2array(testSetup(i).evaluation);
data = struct2array(str);
exportArr = [exportArr;nan;data']
end
This creates an array in the format of the data columns in your excel file.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!