How do I write a combined cell array/struct to excel in a loop, moving one column over for each iteration?
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Mischa Kim
2014-3-13
编辑:Mischa Kim
2014-3-13
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!