Find
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Dear Matlabians
I have one string '14022010_003' and = another
13022010_001
14022010_003
15022010_005
i want to find 14022010_003 in the other string. I try to use find findstr or strfind and it says to me that I need to have same matrix dimensions.
The result i am searching is for the script to give me the number 2 (that this string is in position 2) .Any ideas
Thank you
0 Kommentare
Antworten (5)
karan
am 19 Dez. 2011
a = {'13022010_001';'14022010_003';'15022010_005'};
find(strcmp(a,'14022010_003'))
should give you the index where the string is matched...
0 Kommentare
Nirmal Gunaseelan
am 19 Dez. 2011
Try making the input strings as part of a cell array. Then use STRFIND or STRCMP which will return a logical array of comparisons.
a = {'13022010_001';'14022010_003';'15022010_005'};
strcmp(a,'14022010_003')
ans =
0
1
0
0 Kommentare
Walter Roberson
am 19 Dez. 2011
[tf, idx] = ismember('14022010_003', cellstr(['13022010_001'; '14022010_003'; '15022010_005']) );
0 Kommentare
Daniel Shub
am 19 Dez. 2011
x = '14022010_003'
y = {'13022010_001'
'14022010_003'
'15022010_005'}
find(strcmp(y,x))
Notice the {} and not [] on y.
0 Kommentare
Alexandros
am 20 Dez. 2011
1 Kommentar
Jan
am 20 Dez. 2011
STRMATCH is very inefficient and will be removed in the near future. STRCMP and STRCNCMP are much faster.
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!