如何在 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.
推荐答案
以下链接可能会有所帮助:
The following link might be of help:
http://www.mathworks.com/help/techdoc/matlab_oop/brd4btr.html#brd4nrh
死亡网络档案链接
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屋!
查看全文