How to save the loop data to an excel file in a multilooped program ?

I'm working on a 3-for loop code. I need to store all the loop counter and the inner loop result in excel for all the loop iterations. How should I proceed ?

2 Comments

Do you want to do this in one excell file? are the results the same sizes?
Yes, I want it in the same excel file and the results are of same size.

Sign in to comment.

 Accepted Answer

M=[]
for k=1:10
for ii=1:10
for jj=1:10
% Your code
% If your result A is a matrix 6*4
A=rand(6,4); % Example
R=num2cell(A);
count=cell(size(A,1),1);
count(1:3)={k ;ii; jj};
M=[M;[count R]];
end
end
end
xlswrite('yourfime.xls',M)

More Answers (0)

Community Treasure Hunt

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

Start Hunting!