Why is MATLAB 7.6 (R2008a) slow when I use the COLON operator for array indexing to extract a row from a matrix?
2 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2009-6-27
编辑: MathWorks Support Team
2024-4-17
I am using the COLON operator for array subscripting. In particular, I have a matrix A and I am using
A(i,:)
to obtain the ith row of A. I would like to improve the performance of this operation and make it faster because it exists in a loop with many iterations.
采纳的回答
MathWorks Support Team
2024-4-17
编辑:MathWorks Support Team
2024-4-17
When processing 2-D or N-D arrays, access your data in columns and store it so that it is easily accessible by columns. Accessing columns is faster than accessing rows due to how matrices are stored in memory.
Please see the following URL for Maximizing Code Performance by Optimizing Memory Access:
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!