Filter löschen
Filter löschen

multiply lines of a matrix by a line

1 Ansicht (letzte 30 Tage)
Martin
Martin am 13 Sep. 2013
Hi,
given a matrix A = (Aij) and an horizontal array b = (bj), with B and A of the same width, is there a command that returns a matrix C of the same size as A, and whose each element Cij = Aij * bj ?
I tried C = A .* b but it only works when A is an array as b.
Thanks!

Antworten (1)

Andrei Bobrov
Andrei Bobrov am 13 Sep. 2013
Bearbeitet: Andrei Bobrov am 13 Sep. 2013
try bsxfun:
C = bsxfun(@times,A,b);
  1 Kommentar
Martin
Martin am 13 Sep. 2013
Absolutely perfect. :)
Thanks so much!!

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Operators and Elementary Operations finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by