Speed and Multiple Vectors
显示 更早的评论
Is it faster to operate on multiple individual vectors or to put many vectors into a single matrix and simply reference the columns of the resulting matrix?
采纳的回答
更多回答(1 个)
Star Strider
2014-2-26
0 个投票
I suggest combining them into a single matrix and referencing the columns of the resulting matrix. It’s a lot easier to code and store those results. This works for vectors of equal lengths.
If you encounter the problem of the vectors having different lengths, it°s easy to use a cell array to store them and have them behave essentially as a matrix (except for not being able to use that matrix in matrix computations). It is easy to convert them back to numerical vectors for computation when you need to.
类别
在 帮助中心 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!