Borrar filtros
Borrar filtros

How do I Delete Array Elements

103 visualizaciones (últimos 30 días)
Rick
Rick el 11 de Mzo. de 2013
How do I delete array elements from a list, and then renumber the list in order. This is a 1 dimension array.
For example: If I had an array list of 10 elements: x = [1 2 4 7 8 10 15 18 22 31];
And I want to delete the indexes: 6 7 9 The new list would look like x = [1 2 4 7 8 18 31];
How do I do this ????

Respuestas (1)

Azzi Abdelmalek
Azzi Abdelmalek el 11 de Mzo. de 2013
Editada: Azzi Abdelmalek el 11 de Mzo. de 2013
x = [1 2 4 7 8 10 15 18 22 31];
x([6 7 9])=[]
  1 comentario
Jan
Jan el 11 de Mzo. de 2013
@Rick: This is the most efficient and clean way, and it is explained in the Getting Started chapters of the documentation. It is strongly recommended to read them, because the basics cannot be explained exhaustively in the forum again.

Iniciar sesión para comentar.

Categorías

Más información sobre Multidimensional Arrays 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