Export different excel for each iteration in the for loop (store different matrix for each iteration)
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Juhyeong Ryu
il 28 Lug 2015
Commentato: Juhyeong Ryu
il 8 Mar 2017
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!
0 Commenti
Risposta accettata
Udaya Mallampati
il 30 Lug 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.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!