Info

此问题已关闭。 请重新打开它进行编辑或回答。

Working With Matrices

1 次查看(过去 30 天)
Euan
Euan 2011-11-23
关闭: MATLAB Answer Bot 2021-8-20
I have a matrix and a vector
A= 1 2 3
4 5 6
B=[10 20 30]
Im trying to calculate
C= 1*10 2*20 3*30
4*10 5*20 6*30
Could anyone help me do this? Thanks

回答(1 个)

Jan
Jan 2011-11-23
A = [1 2 3; 4 5 6];
B = [10 20 30];
C = bsxfun(@times, A, B)
Or:
C = A .* B(ones(1, 2), :)

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by