bsxfun to multiply matrix with vector multiple times in for loop --> how faster?
조회 수: 3 (최근 30일)
이전 댓글 표시
I have a 2D matrix of size NxN, and each row I am multiplying with a 1xN vector with bsxfun in a for loop like this:
for k=1:1000
b(k)=mean(bsxfun(@times,tb_filter2d,d(k,:)),2);
end
Is there a way to speed this up? d is of the size 1000xN.
Thank you!!
댓글 수: 4
James Tursa
2017년 3월 6일
If tb_filter2d is your NxN matrix, how does this even work since the result of the RHS is a vector and you are assigning it to a scalar element location b(k)?
답변 (2개)
Ankita Nargundkar
2017년 3월 9일
1. If you are on MATLAB R2016b, you can use operators directly instead of bsxfun. Refer to this example
Something on similar lines, https://www.mathworks.com/matlabcentral/answers/210352-optimize-speed-up-a-big-and-slow-matrix-operation-with-addition-and-bsxfun
댓글 수: 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!