Search a word in a workspace vektor.
3 views (last 30 days)
Show older comments
Dennis Sattelmaier
on 27 Apr 2015
Commented: Dennis Sattelmaier
on 28 Apr 2015
Hi,
I have a Vektor in the Workspace which includes a string.
Now I want to search a 'word' in this vector.
How can I do thios or can help me someone?
2 Comments
Guillaume
on 27 Apr 2015
Dennis' comment moved from Answer to here:
I´m going to explain it better:
My Workspace file look like this:
72 101 108 108 111 32 73 32 97 109 32 51 48 32 121 101 97 114 115 32 111 108 100 46
which means,
"Hello I am 30 years old.".
Now I want to search the word "years" in this Workspace file.
Accepted Answer
Guillaume
on 27 Apr 2015
I don't know what you mean by workspace file. Using proper terminology and examples that are valid matlab commands would help. Possibly you mean this:
v = [72 101 108 108 111 32 73 32 97 109 32 51 48 32 121 101 97 114 115 32 111 108 100 46];
s = char(v); %convert v into characters
yearloc = strfind(v, 'years')
More Answers (1)
Image Analyst
on 27 Apr 2015
If you mean search "FOR" a word, then this will work:
string = 'Now I want to search a "word" in this vector.'
location = strfind(string, 'word')
If you want to literally "search a word" for a particular letter, say 'r', then you can also use strfind() to search inside that word:
string = 'word'
location = strfind(string, 'r')
0 Comments
See Also
Categories
Find more on Environment and Settings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!