Convert cell of strings to numbers
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hallo, On the one hand I have a cell of strings (with around 400 elements) and on the other hand in a loop I have another element (different each time) so I have to find the position of that element at the big array each time. Which is really slow.... so my intention is to convert the cell to numbers (the other string as well) and then just find in the array of number one number.
Is that possible?
Thanks in advance!
2 Kommentare
Azzi Abdelmalek
am 25 Feb. 2015
Bearbeitet: Azzi Abdelmalek
am 25 Feb. 2015
Can you post a short example? and post the code you are using
Akzeptierte Antwort
Guillaume
am 25 Feb. 2015
Neither the ismember nor the indexDictionary indirection is necessary:
aux = find(strcmp(dictionary, value), 1);
In all likelyhood ismember dispatches to strcmp when given strings, so bypass the middleman which you don't need in your case.
Weitere Antworten (2)
Azzi Abdelmalek
am 25 Feb. 2015
str = {'a' 'b' 'c' 'd' 'e' 'f'}
w='c'
out=find(ismember(str,w))
0 Kommentare
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!