Script to take matrix of names and search second matrix returns seemingly random names
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Joseph
am 12 Nov. 2014
Bearbeitet: the cyclist
am 12 Nov. 2014
I'm having trouble understanding where certain output is coming from. I've written a script that is supposed to search through a matrix of first and last name strings and see if they are included in a second matrix. The script then is supposed to return a list of names that it can't find in the second matrix. My problem is that the script spits out several seemingly random names that are included on both matrices. What am I doing wrong and where should I make changes?
if true
% code
end
%%Part 3: Pick names not in both
for k = 1:length(names1);
matchlast = strmatch(last1(k),last2);
matchfirst = strmatch(first1(k),first2);
if rem(matchlast,1) == 0;
rem(matchfirst,1) == 0;
else DTapStlist(end+1,2) = last2(k);
DTapStlist(end,1) = first2(k);
end
end
1 Kommentar
the cyclist
am 12 Nov. 2014
Bearbeitet: the cyclist
am 12 Nov. 2014
Can you post a small example, including values for names1, etc such that your code is self-contained, executable, and exhibits the problem?
Akzeptierte Antwort
the cyclist
am 12 Nov. 2014
You might consider using the ismember command for the task, instead. Seems tailor-made for what you are trying to do.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Characters and Strings 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!