Using something faster than xlswrite()?
3 次查看(过去 30 天)
显示 更早的评论
I am using xlswrite to save the outputs each time, so this calls to open excel and its consuming a lot of time. Is there any other faster process for this ?
0 个评论
回答(2 个)
Star Strider
2016-6-27
I’m not certain what you’re doing, but I would save the intermediate results to a numeric or cell array, then save the array after the loop in one xlswrite call.
Image Analyst
2016-6-27
If by "each time" you mean in a loop, yes, that will take forever, except for more modern versions, like R2015b or later. That's each time you call xlswrite() it has to launch Excel, toss in your data, then shut down Excel. Later versions leave Excel running, which is faster (but which causes other problems by the way). So, what version are you running?
Like Star said, a faster way for all versions is to build your cell array only and THEN write a cell array with a single call to xlswrite().
4 个评论
Image Analyst
2016-6-28
编辑:Image Analyst
2016-6-28
So just store b in a 2D array, then call xlswrite
b2d = zeros(6, 10); % Preallocate for speed.
for column = 1 : 10
% Get b
this_b = whatever.....
% Store in 2D array in this column.
b2d(:, column) = this_b;
end
xlswrite(filename, b2d, 'A1');
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!