how to multiply and concatenate at same time?
Afficher commentaires plus anciens
Dear Matlab guys, I am wondering how to "multiply and concatenate" at same time? Let me write a simple example:
a = [ a b c ; d e f ]
b = [ g h ; i j ]
my idea is to arrive at this:
c = [ ag ah bg bh cg ch ; di dj ei ej fi fj ]
To present it this way I was thinking about the so-called Kronecker product, however I do not think that is the right thing though, since it create hugher matrix. For-loops is possible to do it, but I search for an easier way, - if it exists ?...
thanks in advance, -best Martin B
Réponse acceptée
Plus de réponses (1)
Roger Stafford
le 27 Avr 2013
A method using 'bsxfun':
A = [ a b c ; d e f ];
B = [ g h ; i j ];
[m,n] = size(A);
C = reshape(bsxfun(@times,reshape(A,[m,1,n]),B),m,[]);
1 commentaire
Cedric
le 27 Avr 2013
Neat!
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!