MATLAB: How do you write an excel sheet, and add input to it everytime program is ran

excelimporting excel data

I'm having trouble trying to write an excel spreadsheet that starts with 3 rows of data, but every time the program is ran, new data is input by user and needs to be added to the spreadsheet. how do i do this?

Best Answer

Brute-force approach
[~,~,C] = xlsread('file.xls');
<do stuff to create new data>
<make cell array C2 out of new data>
C = [C;C2];
xlswrite('file.xls',C);
If this is likely to get unwieldy, you could either store information on the number of rows somewhere (like a MAT-file), then use xlswrite to write into a particular range, or you could dive into lower-level ActiveX commands to read/write to Excel.