Multiplying each column with a corresponding row value

Hi everyone,
Let's say I have a matrix of 1 x 5, and another matrix of 3 x 5. I want to multiply every element in each column with its corresponding row value, to obtain the following matrix "C"
A= [ 1 2 3 4 5]
B= [1 2 3 4 5, 6 7 8 9 10, 1 1 2 3 1]
C= [1 4 9 16 25; 6 14 24 36 50; 1 2 6 12 5]
My original matrix has many rows that's why it's difficult to do it by hand
How can I do that?

 採用された回答

Matt J
Matt J 2022 年 4 月 7 日

0 投票

A= [ 1 2 3 4 5]
A = 1×5
1 2 3 4 5
B= [1 2 3 4 5; 6 7 8 9 10; 1 1 2 3 1]
B = 3×5
1 2 3 4 5 6 7 8 9 10 1 1 2 3 1
C= A.*B
C = 3×5
1 4 9 16 25 6 14 24 36 50 1 2 6 12 5

1 件のコメント

Nany
Nany 2022 年 4 月 7 日
That was simpler that I thought! Thanks a lot

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2022 年 4 月 7 日

コメント済み:

2022 年 4 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by