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!