Borrar filtros
Borrar filtros

how can i delete rows from an array ?

2 visualizaciones (últimos 30 días)
ME
ME el 17 de Mzo. de 2015
Comentada: Stephen23 el 18 de Mzo. de 2015
I have an array called pair with dimension 90x2 this contains numbers 1 to 10 in each pair.
e.g 3 7
3 8
3 9
3 10
4 1
4 2
4 3
4 5
and so on ...
I want to be able to delete certain rows from the array e.g delete row (20) and row (50)

Respuesta aceptada

Stephen23
Stephen23 el 17 de Mzo. de 2015
Editada: Stephen23 el 17 de Mzo. de 2015
To delete rows 20 and 50 you can use some basic MATLAB matrix indexing :
A = [your matrix];
A([20,50],:) = [];
Here is a simple example showing how it works:
>> B = [1,6;2,7;3,8;4,9;5,10]
B =
1 6
2 7
3 8
4 9
5 10
>> B([2,4],:) = [] % remove rows two and four
B =
1 6
3 8
5 10
  2 comentarios
ME
ME el 17 de Mzo. de 2015
Thank you
Stephen23
Stephen23 el 18 de Mzo. de 2015
My pleasure! You can also Accept an answer that solves your query :)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrices and 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