提取excel行并在另一列中获取相应的单词

时间:2014-04-04 14:00:41

标签: excel matlab

我准备了一张excel表,其中有两列。在第一列中存储英语单词,在第二列中存储相应的马拉地语单词。我想首先在excel文件中搜索英文单词,如果单词可用,则获取相应的Marathi单词。 matlab中的代码......

1 个答案:

答案 0 :(得分:1)

<强>代码

%%// Replace this with your XLS filepath
FILE = 'list1.xls'; 

%%// Read raw data from xls file
[~,~, rawdata] = xlsread(FILE); 

%%// English word to be translated to marathi. Replace this with your
%%// english word
english_word = 'yes';

%%// Compare the first column that is rawdata(:,1) against the english word 
%%// and returns a binary array with 1s where the match is found
match = ismember(rawdata(:,1),english_word); 

%%// Use the binary array from above to use only the matching row and
%%// return the second column of it, which is our much needed marathi word 
marathi_word = char(rawdata(match,2))

注意:使用xlsread中的第二个输出参数也可以。