How to multiply each element of a matrix by another matrix
12 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Oussama GASSAB
il 26 Apr 2019
Modificato: Oussama GASSAB
il 26 Apr 2019
Suppose two matrices A and B where B=[b11,b12,b13; b21,b22,b23; b31,b32,b33]
i would like to perform the following
C=[A*b11,A*b12,A*b13; A*b21,A*b22,A*b23; A*b31,A*b32,A*b33]
is there any appropriate way do this? faster than the for loop.
thank you in advance.
0 Commenti
Risposta accettata
Andrei Bobrov
il 26 Apr 2019
Modificato: Andrei Bobrov
il 26 Apr 2019
Use function kron:
>> B = reshape(1:9,3,[])
B =
1 4 7
2 5 8
3 6 9
>> A = 2*[1,1;1,1]
A =
2 2
2 2
>> kron(B,A)
ans =
2 2 8 8 14 14
2 2 8 8 14 14
4 4 10 10 16 16
4 4 10 10 16 16
6 6 12 12 18 18
6 6 12 12 18 18
>>
0 Commenti
Più risposte (1)
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!