how to exclude or skip numbers in a for loop

조회 수: 113 (최근 30일)
MS11
MS11 2019년 12월 23일
댓글: KUSHAL JANA 2022년 7월 29일
My code is look like this:
for i=1:12951;
frame=i;
path='.................................';
respath='........................................';
fname=[path,num2str(frame),'.txt'];
thresh=0.4;
picpath='...........................'
(I want to skip some frames value e.g:3147,3148 & 9319,9320 how can i do it?)

채택된 답변

Lucademicus
Lucademicus 2019년 12월 23일
You should take a look at the function ismember
skipNum = [3147,3148,9319,9320];
for i = 1:12951;
if ~ismember(i,skipNum) % if i is not a member of the skipNum array
frame = i;
% further work your magic
end
end
  댓글 수: 5
MS11
MS11 2020년 1월 20일
I know its not a dificult problem but I'm new in this field and just try to learn things. if you can write code for the above problem I'll be gratefull to you
KUSHAL JANA
KUSHAL JANA 2022년 7월 29일
thanx

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by