How to save each iteration of a loop into the same sheet of an Excel spreadsheet?
55 views (last 30 days)
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);
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;
Andy on 13 Oct 2015
xlFilename = 'c:\data\filename.xls';
xlRange = strcat('A',int2str(i));
If your data is a vector this will write each number in cells across the spreadsheet starting in the cell specified by xlRange.
More Answers (1)
Eng. Fredius Magige on 13 Oct 2015
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:
which might assist in row and column arrangment