How to delete multiple elements of an array using for loop?
이전 댓글 표시
I have an array x which is equal to [1:40000]. In every 1000 elements I am trying to delete the first 500 elements I cannot figure this out for the life of me, I think it should look something like x(for loop)=[] I would greatly appreciate help from anyone!
답변 (1개)
Akira Agata
2018년 2월 19일
You don't need to use for-loop. Please try the following:
idx = mod(x-1,1000) < 500;
x(idx)=[];
댓글 수: 1
Jose Camorlinga Medina
2018년 2월 19일
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!