I am trying to sort the output data, I need a help to write data into excel file using for loop.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am trying this, but the excel file is getting rewritten for every iteration and values in the cell are getting replaced. I don't know how to replace the "A2" and "B2" with 'AN' and 'BN' so that for the first iteration the values are written into file's A1, B1 cells respectively... "
u_real = real(u);
v_real = real(v);
for n = 1:100000
if and(u_real>0, v_real>0)
xlswrite('new.xlsx',u_real(n),'sheet1','A2');
xlswrite('new.xlsx',v_real(n),'sheet1','B2');
end
0 commentaires
Réponse acceptée
dpb
le 8 Août 2015
Modifié(e) : dpb
le 8 Août 2015
See the manner in which the sequential file names are generated in How_can_I_process_a_sequence_of_files? Same idea for the cell indices as function of the loop index variable. NB: you can also increment the characters if changing columns by addition in Matlab. That is,
>> char('A'+10)
ans =
K
>>
Of course, if you were to go past 'Z' you'll have to build the two-character indices; Matlab isn't that clever or tied to Excel... :)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Spreadsheets dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!