Dividing a big matrix into small matrices(or Multiply a portion of a matrix to another) to multiply it with a small matrix and after that re add them into the same position.
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Syed Yasir Azeem
am 8 Okt. 2022
Kommentiert: Syed Yasir Azeem
am 9 Okt. 2022
I have a matrix A(400x400) and B(2x2). I want to divide matrix 'A' into 2x2 matrices and multply it with matrix B. Later on Recombine all the matrices from the output into the same locations from where I separated from A.
Example
A = 1 2 3 4 5 6 . . . . B = 1 2
6 5 4 3 2 1 . . . . 3 4
3 2 1 6 5 4 . . . .
5 4 6 1 2 3 . . . .
.
.
I simple want 1 2 ; 6 5 from A to be multiplied with B and restored in the same position and then multiply 3 4 ; 4 3 with B and so on. I am a beginner. Thank you very much
0 Kommentare
Akzeptierte Antwort
KSSV
am 8 Okt. 2022
A = [1 2 3 4 5 6 ;
6 5 4 3 2 1 ;
3 2 1 6 5 4 ;
5 4 6 1 2 3] ;
B = [1 2 ; 3 4] ;
[m,n] = size(A);
k = [2 2];
C = mat2cell(A,k(1)*ones(m/k(1),1),k(2)*ones(n/k(2),1)) ;
[m,n] = size(C) ;
D = cell(m,n) ;
for i = 1:m
for j = 1:n
D{i,j} = C{i,j}*B ;
end
end
iwant = cell2mat(D)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!