I am using R2018b, and trying to use the function 'validtaestring', but it doesn't find a partial match. Has anyone tried that in this version?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Guy Nir
am 20 Nov. 2018
Kommentiert: Guy Nir
am 20 Nov. 2018
STR2={'AA_UCECC'};
str='UCE';
validatestring(str,STR2)
Expected input to match one of these values:
'AA_UCECC'
The input, 'UCE', did not match any of the valid values.
0 Kommentare
Akzeptierte Antwort
Guy Nir
am 20 Nov. 2018
2 Kommentare
Image Analyst
am 20 Nov. 2018
strfind returns an index or an empty null string.
You might want to use contains() like I did in my answer, unless you really need to know the index where the substring starts. If you have just one item, like you did, then you can also use strcmp() or ismember().
Weitere Antworten (1)
Image Analyst
am 20 Nov. 2018
To find partial matches, don't use validatestring(). Use contains
validString = contains(str, STR2);
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!