Borrar filtros
Borrar filtros

How can I make a vector from the elements in the same position across many matrices?

1 visualización (últimos 30 días)
I have 736 matrices of size 72x144. I want to find a vector of 736x1, where each element of the new vector represents the element from the same position in each of the original matrices.
For example:
A = [ 1 2 3 | 4 5 6 | 7 8 9 ]
B = [ 2 2 2 | 3 3 3 | 4 4 4 ]
C = [ 5 4 3 | 1 2 3 | 5 6 7 ]
Want:
D4 (position 2,1) = [ 4 3 1 ]
D5 (position 3,2) = [ 8 4 6 ]
What is the easiest way for me to do this? I can do it manually, but it will take me all weekend. Please help!

Respuesta aceptada

sixwwwwww
sixwwwwww el 30 de Oct. de 2013
Dear Patrick, you can do it as follows:
NumberOfMatrices = 736;
A = randi(100, 72, 144, NumberOfMatrices); % Your 736 matrices
for i = 1:NumberOfMatrices
B{i} = reshape(A(:,:,i)', 1, []);
end
C = reshape((cell2mat(B)), [], NumberOfMatrices); % Each row of C represent one vector of length 736 from corresponding values from 736 matices
I hope it helps. Good luck!

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by