bsxfun to multiply matrix with vector multiple times in for loop --> how faster?
3 views (last 30 days)
Show older comments
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:
Is there a way to speed this up? d is of the size 1000xN.
Ankita Nargundkar on 9 Mar 2017
1. If you are on MATLAB R2016b, you can use operators directly instead of bsxfun. Refer to this example
2. You can use repmat or reshape to optimize. Refer to this link
Something on similar lines, https://www.mathworks.com/matlabcentral/answers/210352-optimize-speed-up-a-big-and-slow-matrix-operation-with-addition-and-bsxfun
Matt J on 10 Mar 2017
Edited: Matt J on 10 Mar 2017
This shouldn't require more than a single vector-matrix multiplication,
Find more on Multidimensional Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!