Export different excel for each iteration in the for loop (store different matrix for each iteration)

3 views (last 30 days)
I would like to export excel file for each iteration in the for loop or store different matrix for each iteration.
what I used in the code is that,
##code
for s=10:10:100
'my code for make a specific scope from raw data'
...
% result is the storage space
numData=size('from the scope');
result=zeros(numData,25);
%calculate within the scope
for i=1:numData
data_new_x = Scope(:,i);
data_mean_x=mean(data_new_x); %mean x
result(i,1)=data_mean_x;
...
end
end
So, by changing the variable s, the output matrix, result, will be different. I would like to store this results for each iteration.
If you have have good idea to solve this problem, please let me know!

Accepted Answer

Udaya Mallampati
Udaya Mallampati on 30 Jul 2015
Hi Juhyeong,
I assume that you would like to write different matrices to different Excel sheets for each iteration of the loop. You can use the following code that does the same:
for i=1:5
A=rand(i,10);
filename=['test',num2str(i),'.xlsx'];
xlswrite(filename,A);
end
You can also write to the same Excel workbook by specifying the sheet name and the range of the cells with in that sheet. Refer to this link that explains about the "xlswrite" function.
Thanks,
Udaya.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!