Fast rewrite all values in a large matrix.
이전 댓글 표시
Now for the purposes of this I'm looking at arrays of sizes(1e+8,50) so obviously very large.
In my code I am pre allocating a zeros matrix called A of data type 'uint8' because I'm not filling the array with numbers greater than 127 or less than 0.
My code rewrites entire columns of this array as such;
idx = [x:y];
%x and y are just two numbers like 1:3 or 5:18
A(1:end,idx) = group;
%group is just an array I have already figured out before hand
Is their a faster way to replace array contents than this, because this takes up the bulk of my run time
댓글 수: 1
dpb
2017년 5월 7일
Try
A(:,idx) = group;
to eliminate the end intrinsic may help but it isn't needed.
I'd wonder if you couldn't fill A while building group instead of having second operation -- "the fastest operation is the one not made".
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!