hi all i have two matrix a 16x1024 and b 16x1
how i can adding b to every column in a ?
No products are associated with this question.
Direct link to this answer:
b_ext = repmat(b, 1, size(a, 2)) ;
c = a + b_ext ;
Direct link to this comment:
I don't understand why it is slower than REPMAT though in cases where size(a,2) is not too large .. I thought that it would kill repmat when I tested.
I haven't tested bsxfun much, but I am not surprised by the timing. I have read many accounts here for various problems and several times it has come up that explicit formulations in one way or another beat bsxfun for speed. For small problems like this one the timing is likely irrelevant anyway.
MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi
Opportunities for recent engineering grads.
New to MATLAB?
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Choose your country to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a location from the following list:
See all countries