How to reshape an M x (aN) matrix into a (aM) x (N) matrix in MATLAB?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Mehmet
am 28 Mär. 2022
Kommentiert: Mehmet
am 28 Mär. 2022
Hey everyone,
I want to reshape an M x (aN) matrix into a (aM) x (N) matrix in MATLAB without using nested for loops?
An example transformation is given below if a=3. (Each square is given with a size of M x N)

0 Kommentare
Akzeptierte Antwort
Bruno Luong
am 28 Mär. 2022
Bearbeitet: Bruno Luong
am 28 Mär. 2022
Use permute
m = 3;
n = 2;
a = 4;
A = reshape(zeros(m,n)+reshape(1:a,[1 1 a]),[m n*a]);
A
B = reshape(permute(reshape(A,[m n a]),[1 3 2]),[m*a n])
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices 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!