Export martrix to excel in Loop
Mostrar comentarios más antiguos
I have a FOR loop in my code and need to save Result ( vertcat of A and B ) in ONE Excel file in new Row(every columns are same) ,but MATLAB save them (each step) in new Excell file !
for Example:
for i=1:5
A=ones(2,5);
B=zeros(3,5);
xlswrite('testdata.xls',[A;B]);
i=i+1;
end
can you help me
6 comentarios
dpb
el 22 de Nov. de 2014
Simplest is to build the entire array in memory and then xlswrite only once after the loop.
Alternatively, you've got to build a dynamic range argument to place the new section where it belongs; what you've told it to do is to write each time starting at cell A1.
dpb
el 22 de Nov. de 2014
Excel can't handle that size an array anyway, can it?
Isay
el 22 de Nov. de 2014
Just because the limitations on the number of rows or columns is greater than the limit, that doesn't necessarily mean Excel has any more system memory than does Matlab...I'd guess 48GB is likely going to bring it to its knees as well...or even if not if it actually will try to page, virtual memory paging will kill you. I don't really think Excel is any "more smarter" than Matlab will be on handling this much data. I don't have 64-bit OS so can't really test it, but just sayin'...
Isay
el 24 de Nov. de 2014
Respuesta aceptada
Más respuestas (1)
Moh
el 27 de Nov. de 2014
try
idx = 0;
for i=1:5
A=ones(2,5);
B=zeros(3,5);
[C,D]=size([A;B]);
xlswrite('testdata.xls',[A;B],1,strcat('A',num2str(1+idx)));
idx = idx+C;
end
Categorías
Más información sobre Spreadsheets en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!