Vectorizing for loop with with strcmp function inside
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I have a very large cell array (A), which has 3 columns with 1066426 rows of data.
What I am trying to do is for each row (row ii), find the one and only row in A (say row j) for which A(j,1) is the same as A(ii,2), & A(j,2) is the same as A(ii,1). Then, get A(j,3) and put it into a structure list (dayne(ii).bsg). Below is my code:
Parfor ii =1:length(A)
dayne(ii).bsg=cell2mat(A((strcmp(A(:,2),A(ii,1)) & strcmp(A(:,1),A(ii,2))),3));
end
The code is working, but its taking a really long time (about 30 mins for 1% to be completed). I have already used parfor to utliize parallel workers.
Can anyone suggest if (and how) this code can be vectorized?
Is there any other way to make it work faster?
Thank you very much for the help.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Structures finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!