MATLAB: I want to write daily datum into xls file without overwriting

column labelingrow labelingxlswrite

Hi All, I have a daily results of some events, which I update them every day and save the previous values as well. Here, I don't want to overwrite the previous values and add the every new date's datas at the end of previous day with their hour and the date of the day. How can I do it in a universal way, so only one run will be enough to store every days data accordingly?
row_headerSecond = {'01.00', '02.00', '03.00', '04.00', '05.00', '06.00', '07.00', '08.00', '09.00', '10.00',...
'11.00', '12.00', '13.00','14.00','15.00','16.00','17.00','18.00','19.00','20.00','21.00','22.00',...
'23.00'};
row_headerFirst = repelem({datestr(today)},23);
xlswrite('myfile.xlsx', data, 'Sheet1', 'C2');
xlswrite('myfile.xlsx',row_header','Sheet1','B2'); %Write row header
xlswrite('myfile.xlsx',row_header1','Sheet1','A2');
Thanks in advance

Best Answer

To append data to an XLS and XLSX file, you have to import the existing data at first to find out, which rows is used already.
Num = xlsread('myfile.xlsx')
Len = size(Num, 1);
New = sprintf('C%d', Len + 1); % Or which range you mean
It is much easier to implement such logging in a text file. Then you can simply append new lines.