I want to add a 20 by 20 matrix to a 50 by 50 matrix ? the resuting matrix should be of 50 by 50 .
Afficher commentaires plus anciens
Réponse acceptée
Plus de réponses (1)
Jos (10584)
le 26 Fév 2015
For arbitrary sized 2D matrices A and B:
% example data
A = ones(3,5)
B = 2*ones(4,2)
% engine
szA = size(A)
szB = size(B)
C = zeros(max([szA ; szB]))
C(1:szA(1),1:szA(2)) = A
C(1:szB(1),1:szB(2)) = C(1:szB(1),1:szB(2)) + B
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!