How to save each iteration of a loop into the same sheet of an Excel spreadsheet?
12 ビュー (過去 30 日間)
古いコメントを表示
Hello, I'm still relatively new to MATLAB.
I am trying to save data into an Excel Sheet, I have successfully managed to save single iteration of the loop in a given sheet. I have managed to save each iteration in a new sheet(as shown below in the code). However, I am interested in saving each iteration in the same sheet but within the following row of the Excel sheet. For example, heading save to row 1. Iteration 1 save to row 2, Iteration 2 save to row 3 and so on.
I understand I can specify the range ('Range','A1') for example to save to row 1. However, I do not know how to make the Range vary in relation to the length of START. What I mean is, if it is Iteration 2 how can I specify 'A3". The end purpose of the code is to generate large amounts of data.
filename = 'Test.xlsx';
z = 1;
START = [0.2:0.1:0.9];
for i = 1:length(START);
start = START(i);
global start;
run 'Improved.' %m.file named 'Improved.m'
Table_1 = table(z,n,A,B,C,D); %variables "z,n,A,B,C,D" are generated within Improved.m
z = z+1;
sheet = z;
writetable(Table_1,filename,'Sheet',z,'Range','A1')
end
Thank you
0 件のコメント
採用された回答
Andy
2015 年 10 月 13 日
xlFilename = 'c:\data\filename.xls';
xlRange = strcat('A',int2str(i));
xlswrite(xlFilename,yourdata,'YourXLSheetName',xlRange);
If your data is a vector this will write each number in cells across the spreadsheet starting in the cell specified by xlRange.
1 件のコメント
Rehannara Beegum Thajudeen
2021 年 10 月 4 日
Thank you for sharing this information, in my code it really worked.
その他の回答 (1 件)
Eng. Fredius Magige
2015 年 10 月 13 日
Hi Iam not competent with the rest, except (note that, if table(table(z,n,A,B,C,D)) is common in coding or your own code), you have:
start(i,1)=START(i); %etc
which might assist in row and column arrangment
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!