So two things I discovered about Matlab while working on this loop.
A) Matlab does not let you modify the index (counter) of a for loop inside of the loop. This should be fixed.
B) Matlab will not allow a for loop to count back/down. This should also be fixed.
The solution, use a while loop and ignore Matlab's crippled implementation of for.
The final code I ended up using:
filelist = ls('*.csv');
j=size(filelist,1);
while j>0
if strcmp(filename,strtrim(filelist(j,1:end)))
filelist(j,:)=[];
j=j-1;
end
if strfind(filelist(j,1:end),'long')
filelist(j,:)=[];
end
j=j-1;
end
Thanks for the help again Walter. Yesterday I just wasn't running on all cylinders apparently.
Karl