Multiple Element Array Multiplication

4 ビュー (過去 30 日間)
Michael
Michael 2014 年 7 月 8 日
コメント済み: Michael 2014 年 7 月 8 日
I have two arrays, and I was wondering how to take one array term by term and multiply it to all elements of another ray. For example:
A = [4 ; 5 ; 2]
B = [7 ; 8 ; 9]
I want to take each individual term of A and multiply them to B to get three separate arrays:
AB4 = [28; 32; 36]
AB5 = [35; 40; 45]
AB1 = [14; 16; 18]
I know I can do this manually (by using A(1) for example), but I will need to this for massive arrays. In fact, one of the arrays for A is of the size and type:
<150902x1 uint8>
Therefore typing it manually is out of the question. Any idea on how to do this?
Any help at all would be appreciated. Thank you in advance!

採用された回答

José-Luis
José-Luis 2014 年 7 月 8 日
result = bsxfun(@times, A, B')
  1 件のコメント
Michael
Michael 2014 年 7 月 8 日
Perfect! Thank you!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by