How to find the product of each element of a matrix by itself and by the other elemets at the same row?
2 次查看(过去 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)));
更多回答(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!