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

조회 수: 5 (최근 30일)
Souarv De
Souarv De 2021년 6월 30일
편집: Souarv De 2021년 6월 30일
% 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.

답변 (1개)

Walter Roberson
Walter Roberson 2021년 6월 30일
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
Souarv De
Souarv De 2021년 6월 30일
@Walter Roberson Sorry walter, initially I formulate the question wrongly. I modified the question now. Kindly give the answer now based on modified question.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by