How do I write a combined cell array/struct to excel in a loop, moving one column over for each iteration?

1 visualización (últimos 30 días)
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

Respuesta aceptada

Mischa Kim
Mischa Kim el 13 de Mzo. de 2014
Editada: Mischa Kim el 13 de Mzo. de 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
  1 comentario
Beverly
Beverly el 13 de Mzo. de 2014
Hi Mischa, thank you so much! My attempt to attend MatLAB training in LA next week was vetoed, haha. I really appreciate your help!

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by