Create an array from others matrix

1 visualización (últimos 30 días)
Romina
Romina el 14 de Oct. de 2019
Comentada: Fabio Freschi el 14 de Oct. de 2019
I need to put "a" matrix one below the other in a single matrix. That is, I need to place in a matrix of dimension a*b x N, where the first b rows correspond to sec=1, from row b+1 to row 2b+1 the second matrix corresponding to sec=2, and so on.
For example for this code:
a=100;
b=5;
N=8;
for sec=1:a
PM=rand(b,N)
end
I want to create the matrix of dimension 500x8, formed by the 100 matrix generated, where the first 5 rows correspond to the matrix obtained for sec = 1, from row 6 to row 11 the second matrix corresponding to the matrix obtained for sec = 2, and so on.
  3 comentarios
Romina
Romina el 14 de Oct. de 2019
My data comes from another code and not from this. In the original code something similar happens, then, for every second i get a 1000 x 1000 matrix.
There were only five rows for the first second and five rows for sec 2. It's 6-10 and not 6-11 as i said before
Bob Thompson
Bob Thompson el 14 de Oct. de 2019
Ok, well the indexing on 'data' should be what you're looking for. I can't write the right hand side of the equation for you because I don't know what it looks like.

Iniciar sesión para comentar.

Respuesta aceptada

Fabio Freschi
Fabio Freschi el 14 de Oct. de 2019
You can just append the matrices as they come.
a=100;
b=5;
N=8;
% inital empty matrix
PM = [];
% your loop
for sec=1:a
PM = [PM; rand(b,N)];
end
  6 comentarios
Romina
Romina el 14 de Oct. de 2019
Yes! That is exactly what I needed! Thank you very very much!
Fabio Freschi
Fabio Freschi el 14 de Oct. de 2019
My pleasure! If my answer solve your original problem, please accept it!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by