Reads ASCII text file into workspace and strips off header.
- out = areadr(file,nline,nvar,flag)
Inputs are (file) an ASCII string containing the file name to be read, (nline) the number of rows to skip before reading or a character string containing the last few characters before the first number to be read (used to skip the header information), (nvar) the number of rows or columns in the matrix to be read, and (flag) which indicates whether (nvar) is the number of rows (flag=1) or the number of columns (flag=2) in the matrix.
AREADR can be incorporated into other routines to read data directly from groups of files. For example, to read the file "mydata.txt" with a 5 line header and 8 columns in the data into the matrix mymatrix:
mymatrix = areadr('mydata.txt',5,8,2)
Given header information in a text file with the following contents:
END OF HEADER INFORMATION
1 2 1 2
2 3 2 3
3 4 3 4
4 5 4 5
The following command will read the 4 rows of data following the character string "END OF HEADER INFORMATION":
mymatrix = areadr('mydata.txt','END OF HEADER INFORMATION',4,1)
For an automatic text file parser which can handle this type of file without knowing the format, see XCLREADR.