What is the equivalent of mmult of excel in matlab?

1 回表示 (過去 30 日間)
Michael Rahul Soosai
Michael Rahul Soosai 2021 年 9 月 10 日
I need to multiply two uneven matrix (1 row, 4 column and 10 row, 4 column) to yield a single value. In excel i used mmult for the same

採用された回答

Steven Lord
Steven Lord 2021 年 9 月 10 日
The * operator performs matrix multiplication, but in order for that operation to be mathematically defined you need to transpose the second matrix (so the number of columns in the first matches the number of rows in the second) and you will receive a 1-by-10 matrix not a single value.
x = [1 2 3 4]
x = 1×4
1 2 3 4
y = reshape(1:40, 10, 4)
y = 10×4
1 11 21 31 2 12 22 32 3 13 23 33 4 14 24 34 5 15 25 35 6 16 26 36 7 17 27 37 8 18 28 38 9 19 29 39 10 20 30 40
z = x*y.' % transpose y
z = 1×10
210 220 230 240 250 260 270 280 290 300
To check:
z6 = 1*6 + 2*16 + 3*26 + 4*36
z6 = 260
z(6)
ans = 260
  1 件のコメント
Michael Rahul Soosai
Michael Rahul Soosai 2021 年 9 月 10 日
Tnank you Sir very much for your time and support

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by