How can I add 2D matrix to 3D one?

2 vues (au cours des 30 derniers jours)
Szabó-Takács Beáta
Szabó-Takács Beáta le 7 Août 2015
Dear All, I would like to add 2D matrix (464x201) to 3D matrix (464x201x31). The matrices contain single elements. These matrices are stored in a cellarray {360,1}. I mean A {360,1} which contains 360 x 3D matrices and B {360,1} contains 360 x 2D matrices. I tried the following solution, but I am not sure, that it is correct. Firstly I converted the cellarrays to 4D matrix with
M = cat(4,A{:}) and
N = cat(4,B{:}).
After that I used the element-by-element binary operation:
T = bsxfun(@plus, M, N).
Could you inform me if it is correct way or there is a better solution. Thank you for your response in advance!

Réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by