how to exclude or skip numbers in a for loop

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?)

 Respuesta aceptada

Lucademicus
Lucademicus el 23 de Dic. de 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 comentarios

MS11
MS11 el 23 de Dic. de 2019
it works.
thankyou so much
Lucademicus
Lucademicus el 23 de Dic. de 2019
you're welcome
Rik
Rik el 20 de En. de 2020
Editada: Rik el 20 de En. de 2020
What have you tried so far? It doesn't seem to be a difficult problem.
Generate the list of files and use a loop to edit them. Inside the loop read the file, add the filename and a space (or tab) to every line and write out again.
If you have any issues implementing that, you might want to Google some examples and after that consider posting a separate question.
Edit: this was already reposted, so any follow up should probably happen there.
MS11
MS11 el 20 de En. de 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
KUSHAL JANA
KUSHAL JANA el 29 de Jul. de 2022
thanx

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Preguntada:

el 23 de Dic. de 2019

Comentada:

el 29 de Jul. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by