loop on a strfind

5 visualizzazioni (ultimi 30 giorni)
Mate 2u
Mate 2u il 6 Lug 2012
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.

Risposte (1)

Jonathan Sullivan
Jonathan Sullivan il 6 Lug 2012
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);

Categorie

Scopri di più su Characters and Strings in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by