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?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/761741/image.png)
댓글 수: 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!