Find all the words contained in a file and make an index

조회 수: 10(최근 30일)
Laura U
Laura U 2019년 10월 1일
답변: Bob Thompson 2019년 10월 1일
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 =
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)))
But I receive this:
Index =
0×1 empty double column vector
I would very much appreciate any help you could give me.

채택된 답변

Bob Thompson
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});

추가 답변(0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by