如何在MATLAB中预分配类的数组? [英] How to preallocate an array of class in MATLAB?
本文介绍了如何在MATLAB中预分配类的数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在MATLAB中有一个对象数组,并在一个循环中调用了它们的构造函数:
I have an array of objects in MATLAB and I've called their constructors in a loop:
antsNumber = 5;
for counter = 1: antsNumber
ant(counter) = TAnt(source, target);
end
MATLAB警告我使用预分配来加快此过程.我确实知道预分配的好处,但是我不知道该如何为对象做这些事情.
MATLAB warns me to use preallocation to speed up the process. I do know the benefits of preallocation but I don't know how to do that for objects.
推荐答案
以下链接可能有帮助:
http://www.mathworks.com/help/techdoc/matlab_oop/brd4btr.html#brd4nrh
死者的Web存档链接
http://www.mathworks.com/help/techdoc/matlab_oop/brd4btr.html#brd4nrh
Web archive of dead link
新链接:
http://de.mathworks.com/help/matlab/matlab_oop/creating-object-arrays.html
这篇关于如何在MATLAB中预分配类的数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文