loop on a strfind
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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.
0 Commenti
Risposte (1)
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);
0 Commenti
Vedere anche
Categorie
Scopri di più su Characters and Strings in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!