how to exclude or skip numbers in a for loop

108 views (last 30 days)
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?)

Accepted Answer

Lucademicus
Lucademicus on 23 Dec 2019
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 Comments
MS11
MS11 on 20 Jan 2020
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

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!