How to delete some specific rows of a column vector simultaneously?

5 visualizaciones (últimos 30 días)
Souarv De
Souarv De el 30 de Jun. de 2021
Editada: Souarv De el 30 de Jun. de 2021
% C2
A = [12
14
24
26
15
11
18
14 ];
A is a column vector. I want a small one-line code/command to delete only 2nd, 5th and 8th rows of A simultaneously. Basically I want to delete those rows in one go/ one run.

Respuestas (1)

Walter Roberson
Walter Roberson el 30 de Jun. de 2021
ARRAY(ARRAY==VALUE) = []; %delete if array is exactly value
or
NEW_ARRAY = ARRAY(ARRAY~=VALUE) %create new vector without disturbing old one
or
ARRAY(ismember(ARRAY, [LIST OF VALUES])) = [] %delete if value is any of the ones in the list of values
  1 comentario
Souarv De
Souarv De el 30 de Jun. de 2021
@Walter Roberson Sorry walter, initially I formulate the question wrongly. I modified the question now. Kindly give the answer now based on modified question.

Iniciar sesión para comentar.

Categorías

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

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by