My query is string = 'Alligator in water'
where in
is a stop word. How can I remove it so that I get stop_remove = 'Alligator water'
as output. I have tried it with ismember
but it returns integer value for matching word, I want to get the remaining words as output.
in
is just an example, I'd like to remove all possible stop words.
Use
regexp
:Use this for removing all stop-words.
Code
Output
NOTE: This code uses
strjoin from Mathworks File-exchange
.A slightly more elegant way than Luis Mendo's solution is to use
regexprep
that does exactly what you wantIf you have several stop words you can simply add them to the pattern (in this example I consider
'in'
and'near'
as stop words):