As I am trying to multiply a m x n
Matrix with a p-dimensional
vector, I am stumbling across some difficulties.
Trying to avoid for loops, here is what I am looking to achieve
enter code here
M = [1 2 3; p = [1;2;3]
4 5 6;
7 8 9]
I want to obtain a 3x3x3
matrix, where the slices in third dimension are simply the entries of M
multiplied by the respective entry in p
.
Help is much appreciated
You can use
bsxfun
withpermute
for avectorized
(no-loop) approach like so -You would end up with -
With
matrix-multiplication
-