MatLab command that will return a matrix that contains the product of every element in two vectors of any length

2 次查看(过去 30 天)
For example
V1 = [10, 20, 30]
V2 = [2, 3, 6]
and the return should be something like
ANS = [20, 40, 60;
30, 60, 90;
60, 120, 180]
I tried to do v1 .* v2 and the return is something like ans= 20 60 180 which is not what I want... any suggestion? thank you

采纳的回答

bym
bym 2012-11-30
V1.'*V2
ans =
20 30 60
40 60 120
60 90 180

更多回答(1 个)

Walter Roberson
Walter Roberson 2012-11-30
kron(V1.', V2)
or
bsxfun(@times, V1.', V2)

类别

Help CenterFile Exchange 中查找有关 Just for fun 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by