Turning a product of two vectors into a matrix without using for loops?
1 次查看(过去 30 天)
显示 更早的评论
I have to two vectors x and y, each of length n. I want a matrix M where the elements of M are . How can I construct M on matlab without using a for loop?
0 个评论
采纳的回答
Star Strider
2021-10-8
I believe something like this should do what you want —
x = 1:10
y = 11:20
M = x(:)*y
Using ‘x’ as x(:) forces it to become a column vector. The rest is straightforward vector-matrix multiplication.
.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!