首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >xlsread [num]丢弃NaN

xlsread [num]丢弃NaN
EN

Stack Overflow用户
提问于 2017-06-02 07:53:29
回答 0查看 84关注 0票数 0

我正在尝试编写一个脚本,以便从Excel文件中读取文本列,检查其内容,然后将另一列(数字)的单元格的内容写入其他excel文件。

代码语言:javascript
复制
function [ output_args ] = export3( filename,cellranges )
%UNTITLED2 Summary of this function goes here
%   Detailed explanation goes here
[~,txt] = xlsread(filename, cellranges);
actRange = strrep(cellranges,'H','D');
[num] = xlsread(filename, actRange);
active = [];
rest = [];
for ii = 1 : length(txt)
    if strcmp(txt{ii},'ACTIVE')
        active(end+1) = num(ii)
    elseif strcmp(txt{ii},'REST-S') 
        rest(end+1) = num(ii);
    end
end
xlswrite('activity.xls',active')
xlswrite('rest.xls',rest')
end

问题是,如果numbers列中有一个索引值,那么它就会被删除,这也会导致txt单元格和num向量之间的不匹配,从而提示“NaN已超出矩阵维度”。错误。我想将NaN值保留在我的数字向量中,我该如何继续?

在excel中可能有一种更好的方法,但我不熟悉它,我只是对Matlab有一些基本的了解。

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44318781

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档