MATLAB: Reading text file of different columns as empty in matlab

bugdata importloadMATLABmatrix arraytext filetextscanvector

My text file consists on 31*13 matrix, Problem is 3nd column which has length of 28, columns no 3,5,8,10,12 are of length 30, Actually this is daily temperature data for one year, I tried, but getting different biases?
Possible read it in matlab, and place NaN value where empty value appear?
Text file has been attached. Looking to hear from you people. Thanks

Best Answer

It used to be tricky to read files like this one with Matlab. I don't know whether The Mathworks provided a solution in a recent release, but I don't think so. I attach a file, which is on-going-work, but it seems to do the job. The file may be called in two ways.
cac = read_fixed_format( 'CHLMIN00.TXT' ...
, '%10f%9f%9f%9f%9f%9f%9f%9f%9f%9f%9f%9f%9f' ...
, 'Headerlines',1 );
cac = read_fixed_format( 'CHLMIN00.TXT', '%10f12(%9f)', 'Headerlines',1 );
test
>> cac{3}'
ans =
Columns 1 through 9
3.4000 3.9000 4.4000 3.1000 2.8000 2.2000 3.1000 3.6000 3.5000
Columns 10 through 18
3.9000 4.2000 3.9000 3.3000 3.3000 5.0000 6.1000 5.0000 5.6000
Columns 19 through 27
4.4000 3.9000 2.8000 3.9000 4.7000 3.9000 3.9000 4.4000 5.0000
Columns 28 through 31
5.0000 5.3000 NaN NaN
&nbsp
Does MATLAB offer a user friendly way to read&nbsp CHLMIN00.TXT ? &nbsp I made the test below with R2016a.
YES, interactively Import Data gets the "empty entries" right, but it seems as is the first empty line of the text file ends up as a row of NaNs at the bottom of the data.
&nbsp
HOWEVER, the function, importdata, makes a mess of the "empty entries". On the other hand, it's not confused by the first empty line.
>> data = importdata( 'CHLMIN00.TXT' );
>> whos data
Name Size Bytes Class Attributes
data 31x13 3224 double
>> data(26:end,3)'
ans =
4.4000 5.0000 5.0000 5.3000 12.2000 10.1000
>>
I'm not amused!