0
votes

I'm currently writing a piece of code which is supposed to import text files using importdata and count the number of columns, i thought the cols() function would suffice for this, but it seems that all the imported data is stored as a double, meaning I can't perform this operation.

M=importdata('title');
numcols=cols(M.data);

Am I doing something wrong? I thought the data fromthe text file would be stored in a matrix/array?

1

1 Answers

1
votes

Cols is a specific function for use in the database toolbox.

You probably just want to use the size function. EG:

size(M.data,2);   %Returns number of columns

FYI

size(M.data, 1); %Returns number of rows.