What is the equivalent of mmult of excel in matlab?
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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]
y = reshape(1:40, 10, 4)
z = x*y.' % transpose y
To check:
z6 = 1*6 + 2*16 + 3*26 + 4*36
z(6)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!