How to find the product of each element of a matrix by itself and by the other elemets at the same row?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Matt Talebi
el 27 de Mzo. de 2015
Comentada: Andrei Bobrov
el 31 de Mzo. de 2015
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 comentarios
Respuesta aceptada
Andrei Bobrov
el 27 de Mzo. de 2015
Editada: Andrei Bobrov
el 31 de Mzo. de 2015
EDIT
[n1,n2] = ndgrid(1:size(x));
y = x(:,nonzeros(tril(n1))).*x(:,nonzeros(tril(n2)));
3 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!