How to find the product of each element of a matrix by itself and by the other elemets at the same row?
조회 수: 1 (최근 30일)
이전 댓글 표시
input:
x = [a,b,c;
d,e,f]
output:
y = [a^2,a*b,a*c,b^2,b*c,c^2;
d^2,d*e,d*f,e^2,e*f,f^2]
댓글 수: 0
채택된 답변
Andrei Bobrov
2015년 3월 27일
편집: Andrei Bobrov
2015년 3월 31일
EDIT
[n1,n2] = ndgrid(1:size(x));
y = x(:,nonzeros(tril(n1))).*x(:,nonzeros(tril(n2)));
댓글 수: 3
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!