Find all the words contained in a file and make an index
5 次查看(过去 30 天)
显示 更早的评论
I import from excel a file that contain all word and created the interested text string (d) :
num,txt,raw] = xlsread('words.xlsx','Hoja1');
d=string(txt);
>>d
d =
Media
Tao
When searching the web, I discovered that in case of being a word, I can do this, and it returns an index value with the location of that string
Index = find(contains(domain(:,1),'Tao'));
The problem is when I wanna use the file string interested as input (d). I make this e.g.
for (i = 1:d)
Index = find(contains(domain(:,1),d(i)))
end
But I receive this:
Index =
0×1 empty double column vector
I would very much appreciate any help you could give me.
0 个评论
采纳的回答
Bob Thompson
2019-10-1
You are on the right track, but you aren't calling the word index correctly. Also, I would suggest using strfind instead of the find(contains(domain( combo. I think it will just provide a more clean answer.
I am having some confusion with your variables, so I am outlining what I am using below. Adjust as you need to.
domain is the large string that you are search and finding indices within.
d is the list of words that you want to find. I am going to assume that it is a cell array of n x 1 size.
Index is the results, where the indices for each word are stored in a numeric array within a cell of Index. The cell number corresponds with the respective word in d.
for i = 1:size(d,1)
Index{i,1} = strfind(domain(:,1),d{i});
end
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Cell Arrays 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!