Export martrix to excel in Loop
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Isay
am 22 Nov. 2014
Kommentiert: Image Analyst
am 27 Nov. 2014
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 Kommentare
dpb
am 23 Nov. 2014
Bearbeitet: dpb
am 23 Nov. 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'...
Akzeptierte Antwort
Image Analyst
am 23 Nov. 2014
If you can't fit the 1,000,000 x 6,000 array (48 GB) in memory, then you have to use ActiveX to send it to Excel. See attached demo.
6 Kommentare
Image Analyst
am 27 Nov. 2014
Isay, I don't know why it does that - according to the help it should not. But try this - it works:
delete('testdata.xls'); % Delete any prior file.
for i=1:5
A=ones(2,5);
B=zeros(3,5);
numberOfRows = size(A, 1) + size(B, 1);
thisRow = (i-1)*numberOfRows + 1
cellReference = sprintf('A%d:E%d', thisRow, thisRow + numberOfRows-1)
xlswrite('testdata.xls',[A;B], cellReference);
end
Weitere Antworten (1)
Moh
am 27 Nov. 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
0 Kommentare
Siehe auch
Kategorien
Mehr zu ActiveX finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!