The asciiread() function was used to read array data from an ASCII file. Some header lines could be skiped by setting headerlines argument. The shape of the array could be set using shape argument.

Read grid data from ASCII file:

rain = asciiread('D:/Temp/ascii/SURF_CLI_CHN_PRE_DAY_GRID_0.5-20120702.txt',headerlines=6,shape=(72,128))
rain1 = rain[::-1,:]
x = arange1(72, 128, 0.5)
y = arange1(18, 72, 0.5)
axesm()
geoshow('country')
layer = contourf(x, y, rain1, 20)
title('Precipitation')
ylabel('Latitude')
xlabel('Longitude')
colorbar(layer)


Read station data from ASCII file. numasciicol() and numasciirow() functions were used to get column and row number of the file:

fn = 'D:/Temp/ascii/flood.dat'
ncol = numasciicol(fn)
nrow = numasciirow(fn)