내 목적은 다음 부분으로 문자열을하게 분할 'f11_data가'그 분할 단어를 포함하고 있는지 여부를 확인하는 것입니다 파일을 반복. 그렇다면, 0을 반환하고, 그렇지 않으면 1을 반환합니다. 저는 100 개의 문자열을 가지고 있지만, 코드 타임에 str/needles 100을 입력하는 것은 의미가 없습니다. 어떻게 루핑을 사용합니까? importdata
을 사용하는 중에 문제가 있습니다. 데이터 가져 오기 및
data = importdata('URL')
needles = regexp(data,'[:/.]*','split') %// note the different search string
for i = 1:2
A11_data = needles{i};
data2 = importdata(strcat('f11_data', int2str(i)));
%feature11_data=(~cellfun('isempty', regexpi(data2, needles, 'once')))
%feature11(i)=feature11_data
~cellfun('isempty', regexpi(data2, needles, 'once'))
end
내가 오류 얻을 : 내가 루프를 사용하여 위의 코드를 수정하는 방법
str1 = 'http://en.wikipedia.org/wiki/hostname';
str2 = 'http://hello/world/hello';
str3 = 'http://hello/asd/wee';
f11_data1 = 'hostname From wikipedia, the free encyclopedia Jump to: navigation, search In computer networking, a hostname (archaically nodename .....';
f11_data2 = 'hell';
f11_data3 = 'hello .....';
needles1 = strcat('\<', regexpi(str1,'[:/.]*','split'), '\>')
needles2 = strcat('\<', regexpi(str2,'[:/.]*','split'), '\>')
needles3 = strcat('\<', regexpi(str3,'[:/.]*','split'), '\>')
~cellfun('isempty', regexpi(f11_data1, needles1, 'once'))
~cellfun('isempty', regexpi(f11_data2, needles2, 'once'))
~cellfun('isempty', regexpi(f11_data3, needles3, 'once'))
이
은 사용 " ??? 오류 ==> regexpi regexpi의 모든 세포는해야합니다 문자열.Error in ==> f11_test2 at 14
~cellfun('isempty', regexpi(haystack, needles, 'once')) "
내부'f11_data1'와'f11_data2'는 무엇입니까? 'data2'는 문자열입니까? – Deve
f11_data1는 f11_data2는 f11_data3는 URL.txt이 STR1, STR2, STR3를 포함하면서 – user3340270