Storing Multiple Arrays into Larger Array

33 vues (au cours des 30 derniers jours)
Ewan
Ewan le 18 Nov 2020
Commenté : Ewan le 18 Nov 2020
I'm working with multiple N by N matrices, with each one corresponding to data taken at a different position. I'd like to store these into a larger matrix that is (M*N) by (M*N) where M is just an integer, in order to show the data changing with position. For example, taking 16 N by N matrices and putting them in a 4 by 4 configuration. Can anyone help me with this? To add further information, I'd like the final large matrix to look like this:
data = [a, b, c, d;
e, f, g, h;
i, j, k, l;
m, n, o, p]
where a, b, c, d... are my N by N matrices taken at position 1, 2, 3, 4...
Thanks in advance!

Réponse acceptée

Stephen23
Stephen23 le 18 Nov 2020
This is easy if you store all of the data in one cell array (rather than in separate variables):
C = {a,b,c,..,p}; % this is how those matrices should be stored!
data = cell2mat(reshape(C,4,4).')
  1 commentaire
Ewan
Ewan le 18 Nov 2020
Thanks, that worked great!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by