How to insert a matrix into another matrix
18 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
David Hill
le 20 Avr 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;
Réponses (0)
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!