MATLAB: Xlswrite in for loop

xlswrite in a loop

I wrote a genetic algorithm code about Travelling Salesman Problem. I want to run the program 100 times (each run includes 5000 iterations). In each run, the program yields the optimal route w.r.t its total distance. I want the computer to write this best solution (it is the first row o a matrix) into an excel file, each solution added in different rows in excel (i.e. the result of first run in row 1 in spreadsheet, the result of second run in second row in spreadsheet and so on). I used xlsread('experiments', L(1,:), 'exp1', 'A(counter):Q(counter)') but dinna work and gave object returned error code: 0x800A03EC. Thanks.

Best Answer

You should not run xlswrite() 100 times, unless you are prepared to wait a long time - a very long time. It will have to launch Excel and shutdown Excel each time you call xlswrite(). It will be so much faster to use ActiveX, and xlswrite1() from the File Exchange. I've posted ActiveX demos here before. Let me know if you want me to post it again here.