file name recognition

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?

 채택된 답변

Fangjun Jiang
Fangjun Jiang 2011년 11월 17일

0 개 추천

[PATHSTR,NAME,EXT,VERSN] = FILEPARTS(FILE) returns the path, filename, extension and version for the specified file. FILEPARTS is platform dependent.

댓글 수: 1

Baba
Baba 2011년 11월 17일
since my directory only contains one type of files. How would I tell to grab, say, first file and and equate it to 'FILE'

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2011년 11월 17일

0 개 추천

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

카테고리

도움말 센터File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

질문:

2011년 11월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by