【发布时间】:2014-04-06 17:29:39
【问题描述】:
我准备了一个 Excel 表,其中有两列。在第一列中存储英语单词,在第二列中存储相应的马拉地语单词。我想首先在 excel 文件中搜索英文单词,如果单词可用,则获取其对应的马拉地语单词。 matlab中的代码...
【问题讨论】:
我准备了一个 Excel 表,其中有两列。在第一列中存储英语单词,在第二列中存储相应的马拉地语单词。我想首先在 excel 文件中搜索英文单词,如果单词可用,则获取其对应的马拉地语单词。 matlab中的代码...
【问题讨论】:
代码
%%// 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 的第二个输出参数也可以。
【讨论】: