multiplying all elements by fellow elements
Mostrar comentarios más antiguos
Dear All, please if i have matrix of [1 2;4 3], i want to write a statement that can multiply every element by their fellow element and give final result in matrix. that is it will perform and give this kind of matrix: [1*1 1*2 1*4 1*3; 2*1 2*2 2*3 2*4] thanks
1 comentario
Stephen23
el 3 de Nov. de 2018
See Bruno Luong's answer for the simple and efficient MATLAB solution.
Respuesta aceptada
Más respuestas (1)
Bruno Luong
el 2 de Nov. de 2018
Not clear what you want but KRON might be what you are looking for
>> A=[1 2; 4 3]
A =
1 2
4 3
>> kron(A,A)
ans =
1 2 2 4
4 3 8 6
4 8 3 6
16 12 12 9
>> kron(A,[1,2])
ans =
1 2 2 4
4 8 3 6
>> kron(A,[1;2])
ans =
1 2
2 4
4 3
8 6
>> kron([1,2],A)
ans =
1 2 2 4
4 3 8 6
>> kron([1;2],A)
ans =
1 2
4 3
2 4
8 6
Categorías
Más información sobre Matrix Indexing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!