【问题标题】:Extract excel row and get the corresponding word in another column提取excel行并在另一列中获取相应的单词
【发布时间】:2014-04-06 17:29:39
【问题描述】:

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

【问题讨论】:

    标签: excel matlab


    【解决方案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 的第二个输出参数也可以。

    【讨论】:

    • 请解释一下这段代码。我没有得到任何东西,因为我是 matlab 新手。
    • @user3498372 添加了丰富的 cmets 以帮助您理解。希望这可以澄清大部分内容。
    • @user3498372 考虑接受满足您问题需求的答案。在此处阅读有关接受答案的更多信息 - stackoverflow.com/help/accepted-answer
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多