Why do I receive an error when reading my file with the CSVREAD or DLMREAD functions from MATLAB?
The CSVREAD and DLMREAD functions seems to ignore the column specification when reading in a file. I get errors when trying to read a non-numeric entry in column 1, even when I've specified to begin reading from column 2 (zero-based numbers). My file is as follows:
row1,row2,row3,row4,row5col1,1,2,3,4col1,5,6,7,8col1,9,10,11,12col1,13,14,15,16
The command I use is:
d = csvread('csvReadTest.csv',1,1)
Here is the error:
??? Trouble reading number from file (row 1, field 1) ==> col1,1,2,3,4\n Error in ==> C:\MATLABR12\toolbox\matlab\iofun\dataread.dll Error in ==> C:\MATLABR12\toolbox\matlab\iofun\textread.m On line 159 ==> [varargout{1:nlhs}]=dataread('file',varargin{:}); Error in ==> C:\MATLABR12\toolbox\matlab\iofun\dlmread.m On line 102 ==> result = textread(filename,'',nrows,'delimiter',delimiter,'whitespace',whitespace, ... Error in ==> C:\MATLABR12\toolbox\matlab\iofun\csvread.m On line 45 ==> m=dlmread(filename, ',', r, c);
Best Answer