Create new matrix based on an existing one
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a big matrix. Now I want to create a new matrix that takes the first value in each column and changes the following 11 values with the fist value. Then I want to take the value of the 13th row for each column and put in in the following 11 rows for each column.
An example for a column:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
I would like to change it to:
1 1 1 1 1 1 1 1 1 1 1 1 13 13 13 13 13 13 13 13 13 13 13 13
This would be an example for a small column. My matrix has the dimension of 253X7690.
Thank you for your help.
0 comentarios
Respuesta aceptada
Jan
el 6 de Mzo. de 2017
A = rand(253, 7690);
B = A(1:12:end, :); % Take every 12th row
C = repelem(B, 12, 1); % Needs Matlab >= 2015a
With older Matlab versions:
Index = repmat(1:12:size(A, 1), 12, 1);
C = A(Index(:), :);
Más respuestas (0)
Ver también
Categorías
Más información sobre Entering Commands en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!