[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Vectorization question

**From**: |
Marco Cecconello |

**Subject**: |
Vectorization question |

**Date**: |
Fri, 16 Oct 2015 09:08:26 +0200 |

**User-agent**: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |

Vectorization question: say I have a matrix A = (a11, a12; a21, a22) and
a vector B = (b1, b2, b3). I want to generate a matrix 2x2x3 C such that
C(:,:,i) = A + b(i). How can I do this without recurring to a for loop?
With repmat I can easily generate the 2 x 2 x 3 array containing copies
of A but how do I add b(i) to each (:,:,i)?

**Vectorization question**,
*Marco Cecconello* **<=**