subrutine to multiplication multidimensional matrix
Ältere Kommentare anzeigen
Can you tell me a subrutine to multiplication multidimensional matrix in Matlab?
thanks
1 Kommentar
Andrei Bobrov
am 14 Mär. 2013
Please give example
Akzeptierte Antwort
Weitere Antworten (3)
James Tursa
am 15 Mär. 2013
1 Stimme
You haven't given an example so we don't really know what you want yet. Maybe it is this, which does a matrix multiply on the first two dimensions:
Jan
am 19 Mär. 2013
A = rand(2,3,2,2);
B = rand(3,2,2,2);
% A simple loop:
R = zeros(2,2,2,2);
for i1 = 1:2
for i2 = 1:2
R(:, :, i1, i2) = A(:, :, i1, i2) * B(:, :, i1, i2);
end
end
Is this what you want? If so, note that this is actually a list of DOT products only. Then reshape B to a [3 x 8] array, A to a [8 x 3] (which needs a permute(A, [1,3,4,2]) also) and multiply these matrices. Finally a reshaping give the same R.
Unfortunately I do not dare to post the code, because I do not have Matlab for testing at the moment.
agustin darrosa
am 19 Mär. 2013
0 Stimmen
Kategorien
Mehr zu Matrix Indexing finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!