Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

File names

Asked by Alexandros on 10 Jan 2012

I have a script that is asking me what files should it manipulate.

the two categories of files are

Hello1_14022011_1_XV_xls and Hello1_14022011_1_SF_XV_xls

when the question arise (so that the program can make the directory of all the files and manipulate them) in the program i put Hello1_****2011_*_XV_xls for the first category. The problem is that the fifth * will make the program to understand both the categories.

Is there a a way to stop the name reading at those situations?

Thanks

0 Comments

Alexandros

Tags

Products

No products are associated with this question.

2 Answers

Answer by Daniel on 10 Jan 2012
Accepted answer

What about using '?' instead of '*', and why do you have '****', are you sure you don't want that to be ????

10 Comments

Alexandros on 11 Jan 2012

if strfind(file '_SF_')>0
list1(file).name = []
end

this will make me the same size list but without the name. How can i cut the list only with the names i need ? I don't know if I am very clear if you need more info tell me

Daniel on 11 Jan 2012

I think your best bet is to look at the script and figure out how it is doing the wildcard expansion. Without that I cannot help answer your question any more than I have. The question about how to remove the field from your struct array is a new question. Ideally, this would be asked as a new question with the relevant details. You will get more (and better) feedback and it will help others in the future find the question. I think the answer you are looking for is: list1(file) = []; (note I intentionally left out the ".name" part.

Image Analyst on 11 Jan 2012

for k = 1 : numberOfFiles
if strfind(list1(k).name, '_SF_') <= 0
% No SF in the name
% Do stuff
else
% Has SF, so do nothing or do other stuff.
end
end

Daniel
Answer by Image Analyst on 10 Jan 2012

Use strfind(filename, '_SF_') to determine if your filename belongs to the second category. Then only process the filename of the category you're interested in.

0 Comments

Image Analyst

Contact us