# HG changeset patch # User Rik # Date 1351024635 25200 # Node ID 13206177060be3db1b6f55219a7c36bb013c327b # Parent 427020b2ceaf1e63bd72209771fa3e68173e7fce importdata.m: 3X speedup by using str2double rather than num2str. * importdata.m: 3X speedup by using str2double rather than num2str. diff --git a/scripts/io/importdata.m b/scripts/io/importdata.m --- a/scripts/io/importdata.m +++ b/scripts/io/importdata.m @@ -193,10 +193,6 @@ ## Read file into string and count the number of header rows file_content = fileread (fname); - ## The characters need to be in a row vector instead of a column - ## vector to be recognized as a proper string. - file_content = file_content(:)'; - ## Split the file into rows (using \r\n or \n as delimiters between rows). file_content_rows = regexp (file_content, "\r?\n", "split"); @@ -275,7 +271,7 @@ for j=1:length(row_data) ## Try to convert the column to a number, if it works put it in ## output.data, otherwise in output.textdata - data_numeric = str2num (row_data{j}); + data_numeric = str2double (row_data{j}); if (!isempty (data_numeric)) output.data(i-header_rows, j) = data_numeric; else @@ -293,9 +289,9 @@ output.colheaders = output.textdata(end,:); endif - ## When delimiter = "\\t" convert it to a tab, as is done in the Matlab - ## version - if (strcmpi (delimiter, "\\t")) + ## When delimiter = "\\t" convert it to a tab, done for Matlab compatibility. + if (strcmp (delimiter, '\t')) delimiter = "\t"; endif + endfunction