Export martrix to excel in Loop
이전 댓글 표시
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
dpb
2014년 11월 22일
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
2014년 11월 22일
Excel can't handle that size an array anyway, can it?
Isay
2014년 11월 22일
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
2014년 11월 24일
채택된 답변
추가 답변 (1개)
Moh
2014년 11월 27일
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
카테고리
도움말 센터 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!