How do I write a combined cell array/struct to excel in a loop, moving one column over for each iteration?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
My variable Cyc(iiFile).Dch{n} encompasses the file number iiFile and the cycle of discharge (n). For simplicity, I called n = 1. I want to write starting in column B2 for iiFile = 1 and move to C2 for iiFile = 2, etc. Eventually, I will want to add in the 2nd discharge cycle for n = 2 beside each n=1 column vector. The code below works, but keeps overwriting the column vector under cell index B2.
for t = 1:iiFile % for n = 1 to numel( n=1; xlswrite('Test_Data.xlsx',Cyc(iiFile).Dch{n},'Dch','B2') end
0 commentaires
Réponse acceptée
Mischa Kim
le 13 Mar 2014
Modifié(e) : Mischa Kim
le 13 Mar 2014
Beverly, use strcat to modify the cell name you need to write to:
C(1).D = 'b'; % some random data
C(2).D = 'c';
C(3).D = 'd';
for ii = 1:3
sheet = 1;
range = strcat(char(65 + ii),'2'); % create excel cell name
xlswrite('Test_Data.xlsx',C(ii).D,sheet,range)
end
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!