How to delete values when value is 3&4 then 7&8 then 11&12....

조회 수: 3 (최근 30일)
CalebJones
CalebJones 2020년 2월 13일
편집: CalebJones 2020년 2월 15일
I have attached a mat file below.
1 repeates like 162 times
2 repeates like 172 times
I want to
keep 1 & 2
remove 3&4
keep 5&6
remove 7&8
keep 9&10
remove 11&12
so on.......

채택된 답변

Temu Gautama
Temu Gautama 2020년 2월 13일
Hi,
Something like
A(rem(A+1,4)>1)
hth,
Temu
  댓글 수: 3
CalebJones
CalebJones 2020년 2월 15일
편집: CalebJones 2020년 2월 15일
Hey @Temu Gautama
The following part works perfectly
tmp.eventid(rem(tmp.eventid+1,4)>1));
However when I'm doing the following it doesn't seem to work. What I mean is from all results it now removing rows with eventid 1,2 keep...3,4 remove....5,6 keep....7,8 remove so on....
tmp = allresults;
tmp = tmp(find(tmp.eventid(rem(tmp.eventid+1,4)>1)),1:4);
CalebJones
CalebJones 2020년 2월 15일
tmp = allresults;
tmp = tmp(find(rem(tmp.eventid+1,4)>1),1:4);
Fixed it.

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

추가 답변 (1개)

KSSV
KSSV 2020년 2월 13일
If you have an array A...To remove a specific element use:
A(A==val) = [] ;
  댓글 수: 2
CalebJones
CalebJones 2020년 2월 13일
Val has to be manually entered right, I want to code it such with some sort of logic.
KSSV
KSSV 2020년 2월 13일
val can be 3, 4, 7, 8 etc,.

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by