Effacer les filtres
Effacer les filtres

file name recognition

1 vue (au cours des 30 derniers jours)
Baba
Baba le 17 Nov 2011
I have a directory wich can containn files.A XOR files.B
I need to write code to dell if the extension is A or B and based on that assign myfunct=AA() or myfunct=BB()
any suggestions appreciated?

Réponse acceptée

Fangjun Jiang
Fangjun Jiang le 17 Nov 2011
[PATHSTR,NAME,EXT,VERSN] = FILEPARTS(FILE) returns the path, filename, extension and version for the specified file. FILEPARTS is platform dependent.
  1 commentaire
Baba
Baba le 17 Nov 2011
since my directory only contains one type of files. How would I tell to grab, say, first file and and equate it to 'FILE'

Connectez-vous pour commenter.

Plus de réponses (1)

Walter Roberson
Walter Roberson le 17 Nov 2011
filelist = dir();
filelist([filelist.isdir]) = []; %remove . and ..
for K = 1 : length(filelist)
[pathstr, name, ext, versn] = fileparts(filelist(K).name);
if strcmp(ext,"A")
myfunct = AA();
else
myfunct = BB();
end
end
  1 commentaire
Baba
Baba le 17 Nov 2011
thank you

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by