0
我試圖寫一個腳本來從Excel文件中讀取文本列,檢查內容,然後將另一列(數字)的單元格的內容寫入其他Excel文件。xlsread [num] discarding NaN
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
的問題是,如果在數字列NaN值,它只是消除,同時造成,即提示一個txt的細胞和num矢量之間的不匹配的索引超過矩陣的尺寸。「錯誤。我想將NaN值保留在我的數字向量中,我該如何繼續?
在excel中可能有更好的方法,但我不熟悉它,我只是有一些關於Matlab的基本知識。