How to reference groups of rows in a matrix
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Nick Thomas
el 22 de Abr. de 2018
Respondida: Walter Roberson
el 22 de Abr. de 2018
I have a large matrix and want to reference certain rows of it all at once. For example,
Rows 130 to 255
Rows 258 to 383
Rows 386 to 511
and so on... all the way down to
Rows 1666 to 1791
So... groupings of 125 with a space of 3 apart.
I've tried a couple approaches, one being a combination of for and if loops using Boolean operators to exclude multiples of 129 and 128. I couldn't get this to work and would prefer not to use this method as I'll be repeating the process with gaps much larger than 3.
I've also tried a combination of colons but can't seem to get it right.
0 comentarios
Respuesta aceptada
Walter Roberson
el 22 de Abr. de 2018
idx = 130:size(YourMatrix,1);
idx(127:128:end) = [];
idx(127:127:end) = [];
submatrix = YourMatrix(idx,:);
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices 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!