Matrix Manipulation
Información
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Mostrar comentarios más antiguos
Hello everyone!
I am a layman for Matlab, so please forgive me if the question sounds naive. Here is my question. Let's say I have a 3x3 matrix called X:
X = [1 2 3;4 5 6; 7 8 9]
I would like to generate a new matrix Z from X such that every cell Z(i,j) will be defined as follows:
Z(i,j) = X(i,k)*X(k,j) .
where the total number of X cells which are multiplied depends on the length of the matrix.
For example, the first cell of Z will be Z(1,1) = X(1,2)*X(2,1) * X(1,3)*X(3,1)* X(1,1)*X(1,1).
Can any one tell me how to code this in matlab?
Thanks! A.
Respuestas (1)
Andrei Bobrov
el 19 de Nov. de 2011
Z = prod(bsxfun(@times,permute(X,[1 3 2]),permute(X,[3 2 1])),3);
La pregunta está cerrada.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!