How to insert a matrix into another matrix
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a vector of a length up to 2500. How do I reshape this vector of any size up to 50x50 (For example if I don't have 2500 elements, and only have 625, how would I reshape that into a 25x25) and then insert it into a specific point on a 256x256 matrix.
I basically need to insert a smaller matrix into a larger one at a specific point. I am thinking I need to use a for loop.
1 Kommentar
David Hill
am 20 Apr. 2020
If you only have 625 elements, you cannot get a 2500 element matrix. You would have to pad with nan's or zeros or something. Additionally, you did not describe how you wanted the element arraigned in the 50x50 matrix. Inserting a 50x50 matrix into an existing 256x256 matrix is not hard. If m is the 50x50 matrix and M is the 256x256 matrix, then:
M(a:a+49,b:b+49)=m;
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!