0

I'm trying to write a script to read a text column from an Excel file, checking the content, and then writing the content of the cells of another column(numeric) into other excel files.

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

The problem is that if there is a NaN value in the numbers column, it's just eliminated, causing also a mismatch between the txt cell and num vector, that prompt an 'Index exceeds matrix dimensions.' error. I would like to keep the NaN value in my numbers vector, how can I proceed?

There s probably a better way to do it in excel, but I am not familiar with it, I just have some rudimentary knowledge of Matlab.

EBH
  • 10,350
  • 3
  • 34
  • 59

1 Answers1

0

Oh, I figured it out, it was a stupid question, I can just use raw and export everything in a cell array instead of a vector.

EBH
  • 10,350
  • 3
  • 34
  • 59