write in multiple rows in excel

5 views (last 30 days)
Hello everyone, I have a loop (n=30), each loop gives me different results. I want to write the result of the first loop at the first row in an excel sheet, and when the code goes to the next loop it will give me another set of results and I need these new results to be written at the second row in the excel sheet and the same for the last loop (n=30). I wonder if that possible in the matlab. Thanks in advance.

Accepted Answer

Image Analyst
Image Analyst on 28 Sep 2018
Yes. Let's say that you have 100 results at each iteration stored in a row vector. Try this
allResults = zeros(30, 100);
for k = 1 : size(allResults, 1)
theseResults = .... some row vector that you generate somehow ....
allResults(k, :) = theseResults;
end
xlswrite(xlFileName, allResults);
Basically you build up a matrix one row at a time then write the thing all at once in one single call to xlswrite().

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!