how to write xlswrite command in a loop such that after every loop, the row increments.
Show older comments
the program currently stores the values in a ".out" extension. need to store the output to an excel file also. how to add loop such that each calculated value of A gets stored in the next row.
filename = 'testdata.xlsx';
A = [tsince ro(1) ro(2) ro(3) vo(1) vo(2) vo(3)];
sheet = 1;
xlRange = 'A1';
xlswrite(filename,A,sheet,xlRange);
1 Comment
usama amjid
on 10 Jul 2015
Edited: usama amjid
on 10 Jul 2015
Answers (1)
ag
on 29 Dec 2024
Hi Usama,
To write the output to an Excel file, appending it to the next available row, you can utilize the "writematrix" function in MATLAB. Below is a code snippet demonstrating this approach:
% this will append the data below the existing data in the spreadsheet file.
writematrix(mat,'fileName.xls','WriteMode','append')
Please note, "xlswrite" is no longer recommended, kindly refer to the following MathWorks documentation for more details: https://www.mathworks.com/help/matlab/ref/xlswrite.html#mw_88a93783-cc81-4dbc-8146-46289887a551:~:text=is%20not%20recommended-,xlswrite%20is%20not%20recommended,-.%20Use%20writetable%2C
Hope this helps!
1 Comment
Walter Roberson
on 29 Dec 2024
Note: writematrix() did not exist when the question was first asked in 2015.
Categories
Find more on Spreadsheets in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!