matrix and vector

1 visualización (últimos 30 días)
Malgorzata
Malgorzata el 9 de En. de 2012
Hi How should be written a code to multiply a vector (1x n) with matrix (n x n) and get a result as a matrix .Each element of vector should be multipied with coresponding column of matrix i.e. : 1-st element with 1-st column then 2-nd with 2-nd .The command kron gives the desired outcome but it is too vast and every n+n of its outcome is that I am interested in .Thank for any clue !

Respuesta aceptada

Sean de Wolski
Sean de Wolski el 9 de En. de 2012
doc bsxfun
and more specific:
bsxfun(@times,matrix,vector)

Más respuestas (1)

Jonathan Sullivan
Jonathan Sullivan el 9 de En. de 2012
If your vector is V with elements V1-VN and your matrix is M with elements M11-MNN, I presume you want the a matrix containing the following:
[V1*M11 V2*M21 ... VN*MN1
V1*M12 V2*M22 ... VN*MN2
.
.
.
... VN*MNN]
You can do that by simply typing the following:
result = bsxfun(@times,V,M);
  1 comentario
Malgorzata
Malgorzata el 9 de En. de 2012
THANKS, that is it

Iniciar sesión para comentar.

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by