我正在尝试编写一个脚本,以便从Excel文件中读取文本列,检查其内容,然后将另一列(数字)的单元格的内容写入其他excel文件。
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有一些基本的了解。
https://stackoverflow.com/questions/44318781
复制相似问题