I have a vector A = and a matrix X = , where is a M-dimensional row vector. Does matlab have an operator that directly give me the matrix? (where each row vector in the above matrix X is multiplied by the corresponding part in vector A)

 採用された回答

Dyuman Joshi
Dyuman Joshi 2023 年 12 月 8 日
編集済み: Dyuman Joshi 2023 年 12 月 8 日

1 投票

If I understand your question correctly, you should get the desired output using array multiplication -
N=5;
A = (1:N).'
A = 5×1
1 2 3 4 5
X = magic(N)
X = 5×5
17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9
Z = A.*X
Z = 5×5
17 24 1 8 15 46 10 14 28 32 12 18 39 60 66 40 48 76 84 12 55 90 125 10 45

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Creating and Concatenating Matrices についてさらに検索

製品

リリース

R2023a

質問済み:

2023 年 12 月 8 日

編集済み:

2023 年 12 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by