How do I initialize an array of unknown dimension?
显示 更早的评论
I have a vector whose length is not known apriori. The programs gives a warning with red wiggles underneath indicating that the size of the array varies each loop and preallocating the size is a good idea. But how do I do that since I do not know what is the size going to be.
1 个评论
Geoff Hayes
2018-3-12
Pappu - do you have an idea of the size of the array? You could pre-allocate to some large size and then reduce the size of the array at the end if there are any "unused" elements.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!