Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How to make the folders correspond to suitable files depending on its similar names

조회 수: 1 (최근 30일)
I have folders' names in a variable nameFolds1("DYT" "HC9" "HC" "MS_3R" "MS" "PN5_3R" "T"). The 'files' variable contains names of files(like DYT02_OFF,HC907,HC505,MS010_3R,MS010,PN532_3R,T27).
So each folder name should head the corresponding list of files. With DYT, HC9, HC and T it's easy, because I can just use the startswith function.
The problem with MS_3R and PN5_3R, that its files have some numbers before the _ sign(e.g. MS010_3R and PN532_3R). If somebody knows how to deal with it, answer me please.
for i = 1:Numb_of_folds
pattern = nameFolds1(i);
TF = startsWith(files,pattern);
Z = files(TF);
files(ismember(files,Z)) = [];
s = size(Z);
Z = cellstr(Z.');
fprintf(fid1,'%s\r\n',Z{:});
fprintf(fid1,'\n');
end

답변 (0개)

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by