필터 지우기
필터 지우기

loop on a strfind

조회 수: 1 (최근 30일)
Mate 2u
Mate 2u 2012년 7월 6일
Hi all, I have a loop as such:
parfor i =1:1000000
ZZ= strfind(A2,lm(i,:));
end
now this lm is fine it's a set of strings of size 10 (many of them). And A2 is a large string.
I need to modify this...I have another string B2.
I need to do it so that at the first iteration the strfind looks in A2, then in the second iteration (i=2) then it looks in [A2 B2(1)], then on third iteration it looks in [A2 B2(2)] etc....
If anybody needs clarification I will rewrite question. Thank you.

답변 (1개)

Jonathan Sullivan
Jonathan Sullivan 2012년 7월 6일
I think this can be done with arrayfun.
% Your inputs
A2 = 'Number';
B2 = '0123456789';
lm = char(randi([32 64],10,100));
% Make the thing strings you want to find
ABz = strcat(A2,B2(:));
% Find them
out = arrayfun(@(ind) strfind(ABz{ind,:},lm(ind2,:)).1:length(ABz),'uni',false);

카테고리

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