Prev: ezdsp R2812 using matlab
Next: Trouble with hilbert()
From: Matt on 4 Jun 2010 10:25 Hi, I'm trying to write an 'if' statement that skips out a certain file with 'eng' contained within the file name during a loop processing a series of files with different names. I basically want it to say: if 'eng' is part of the filename then do not conduct the process for that file... I assume 'continue' will do this but I don't know how to tell Matlab to look for 'eng' in the file name. Sorry I'm not the best at explaining! Hope it makes sense. Thanks!
From: Walter Roberson on 4 Jun 2010 10:30 Matt wrote: > I'm trying to write an 'if' statement that skips out a certain file with > 'eng' contained within the file name during a loop processing a series > of files with different names. > I basically want it to say: if 'eng' is part of the filename then do > not conduct the process for that file... > > I assume 'continue' will do this but I don't know how to tell Matlab to > look for 'eng' in the file name. See strmatch()
From: ImageAnalyst on 4 Jun 2010 10:59 Matt: I'd use strfind(). If it is not empty upon returning, the substring is in there filename = '1234.png' index1 = strmatch(filename, 'eng') index2 = strfind(filename, 'eng') if ~isempty(index2) message = sprintf('eng is at index %d in the string %s', index2, filename); else message = sprintf('eng is not in the string %s', filename); end uiwait(msgbox(message)); filename = '123_eng_9.png' index1 = strmatch(filename, 'eng') index2 = strfind(filename, 'eng') if ~isempty(index2) message = sprintf('eng is at index %d in the string %s', index2, filename); else message = sprintf('eng is not in the string %s', filename); end uiwait(msgbox(message)); Results: filename = 1234.png index1 = [] index2 = [] filename = 123_eng_9.png index1 = [] index2 = 5
|
Pages: 1 Prev: ezdsp R2812 using matlab Next: Trouble with hilbert() |