How to select desired row

1 visualización (últimos 30 días)
Setiadi Suriana
Setiadi Suriana el 25 de Abr. de 2019
Comentada: Setiadi Suriana el 26 de Abr. de 2019
I have a workspace A with value 81536x10 double. I want to take create new workspace from workspace A with row 1 to 112, 225 to 336, 449 to 560 and so on.

Respuesta aceptada

Jos (10584)
Jos (10584) el 25 de Abr. de 2019
ix = [0:224:81563]' + 1:112 ; % calculate row indices
ix(ix>size(A,1)) = [] % remove row indices that are too larger
A2 = A(ix, :) % a single array
Alternatively, you can store each section in a cell array
A3 = arrayfun(@(k) A(k:k+111, :), 1:224:81563, 'un', 0) % no check of indices
  5 comentarios
Jos (10584)
Jos (10584) el 25 de Abr. de 2019
Oh, this might be related to your version of ML.
A = randi(100,6,2)
ix = bsxfun(@plus,[0:1]', 1:4:size(A,1))
A(ix,:)
should return rows 1-2 and rows 5-6 of A
Setiadi Suriana
Setiadi Suriana el 26 de Abr. de 2019
Thank you, now it is working

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Etiquetas

Productos


Versión

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by