hTeeML
hTeeML

Reputation: 61

How to use xlRange in Matlab when it is in a loop and avoid overwriting on same cell?

I have a loop where it keeps producing answers each time. I need to record about 200 of these answers in excel. But instead of writing one by one I thought of using xlswrite. Then I realised this keeps over writing the data on same cell. Then I thought of xlRange but I don't know how to increase this from A1 to A2 so each loop answer gets recorded in a different cell.

xlswrite(filename,array,sheet,xlRange)
xlRange = 'A1'

This is what I am using currently but I need the xlRange to increase each time.

I am new to Matlab so is this a right command to use to be able to record my answers on excel. Also is there a way to solve this?

Thank you

Upvotes: 0

Views: 832

Answers (1)

Derek
Derek

Reputation: 657

Following @excaza's advice, here's an example

toWrite = cell(5);
for k = 1:5
    toWrite{k, k} = char(97 + k - 1); % writes 'A', 'B', ..., 'E'
end
xlswrite('test.xlsx', toWrite);

Upvotes: 0

Related Questions