フィルターのクリア

multiply lines of a matrix by a line

1 回表示 (過去 30 日間)
Martin
Martin 2013 年 9 月 13 日
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!

回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2013 年 9 月 13 日
編集済み: Andrei Bobrov 2013 年 9 月 13 日
try bsxfun:
C = bsxfun(@times,A,b);
  1 件のコメント
Martin
Martin 2013 年 9 月 13 日
Absolutely perfect. :)
Thanks so much!!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeOperators and Elementary Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by