Compare 2 strings without using ismember or strcmp
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
flashpode
am 27 Sep. 2021
Kommentiert: flashpode
am 27 Sep. 2021
Hi, I've got a code that gives me different outputs and I want to compare the messages inside them and the ones that are not in one string(X) and are in the other(Y) write them into another output. Lets see:
K is the number of messages that has an string.
If K from X is not in Y = L
And I do not want to use ismember or srcmp because the proces would be very long.
I guess I have explained myself.
Thank youuu for the answer!!!
4 Kommentare
Akzeptierte Antwort
Stephen23
am 27 Sep. 2021
Bearbeitet: Stephen23
am 27 Sep. 2021
Presuming that your examples with invalid syntax are actually supposed to be string arrays:
a = ["qwert34776";"dnfien/8863";"feihfidi234";"939405'cncieni";"300oppdf";"din2004ms"];
b = ["qpwn3feini";"300oppdf";"hfgt4568";"qwert34776";"dnfien/8863"];
c = setdiff(a,b)
Most likely using SETDIFF will be faster than writing your own function (including time to write, time to test, time to debug, time to maintain, and runtime).
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Whos 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!