Why is MATLAB 7.6 (R2008a) slow when I use the COLON operator for array indexing to extract a row from a matrix?
조회 수: 1 (최근 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!