필터 지우기
필터 지우기

list handeling

조회 수: 5 (최근 30일)
Alexandros
Alexandros 2012년 1월 11일
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?
By doing a if loop i can have some results
for ilistA = 1:length(listA)
if strfind (listA(ilistA).name, '_SF_')>0
listA(ilistA).name = []
end
end
This will make me the list with only the names of files I need and a blank spot in the place of the files i didnt need. How can i cut the blank sports and make the list only with the names I need.
Any other ideas are accepted :) Thanks

답변 (1개)

Daniel Shub
Daniel Shub 2012년 1월 11일
listA = struct('name', {'a', 'b', 'x_SF_y', 'c', 'd', 'a_SF_b'});
listA = listA(cellfun(@isempty, strfind({listA.name}, '_SF_')))

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by