How can I divide multiple matrices into individual arrays?
Mostrar comentarios más antiguos
Good afternoon,
Sorry for bothering you, but I have encountered an issue when trying to separate multiple matrices into individual array. I have 8 matrices, each having a dimension of 500x500, and by wanting to store them separately I mean that there should be 250.000 arrays, each containing 8 values. For instance (using a smaller example):
A = [1, 2, 3; 4, 5, 6; 0 0 0]
B = [3, 2, 1; 6, 5, 4; 0 0 0]
The arrays should be like this:
array1 = [1, 3]
array2 = [2, 2]
array3 = [3, 1] and so forth.
The issue consists of, when using "for" loops, I cannot assign an index to an array, like in C++, for instance, having "array1", "array2" etc., but values being overwritten one over another. I would like, if you can help me in managing how to generate arrays regarding a variable, like so (I am referring at the example above, for better explaining the issue):
for k = 1:2;
for i1 = drange(1:size(A, 1))
for j1 = drange(1:size(A, 2))
for i2 = drange(1:size(B, 1))
for j2 = drange(1:size(B, 2))
v(k) = [A(i1, j1), B(i2, j2)]; %k is not dimension, or position
end
end
end
end
end
I would like "k" to be as an index, creating new arrays of dimension 2 at every iteration.
Thank you for your time and I am waiting for your suggestions!
Best regards,
Alin-Marian Sipica
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Matrix Indexing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!