Merge two or more matrices while overlapping them
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Sudip Karmacharya
el 9 de Dic. de 2020
Comentada: Sudip Karmacharya
el 9 de Dic. de 2020
I want to merge two matrices like shown below. Where, overlapping cells are added together to create a bigger matrix.
The columns and rows of A and B, have a differnent "global ID". When they are combined together, whichever cells have overlapping ID, are summed up.

0 comentarios
Respuesta aceptada
Image Analyst
el 9 de Dic. de 2020
Assuming they're double arrays rather than cell arrays, try this:
A = [a, b; c, d]
B = [1, 2; 3, 4];
D = zeros(3, 3);
D(1:2, 1:2) = A; % Put A in
% Now add in B
D(2:end, 2:end) = D(2:end, 2:end) + B
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!