fopen :Open file, or obtain information about open files
例如
fid = fopen(filename, permission)%许可包括:
'r' Open file for reading (default).
'w' Open file, or create new file, for writing; discard existing contents, if any.
'a' Open file, or create new file, for writing; append data to the end of the file.
'r+' Open file for reading and writing.
'w+' Open file, or create new file, for reading and writing; discard existing contents, if any.
'a+' Open file, or create new file, for reading and writing; append data to the end of the file.
'A' Append without automatic flushing; used with tape drives.
'W' Write without automatic flushing; used with tape drives.
fclose Close one or more open files
ST = FCLOSE('all') closes all open files, except 0, 1 and 2.如果输入参数'all',则关闭除0,1,2之外的文件。
feof Test for end-of-file
ST = feof(fid) returns 1 if the end-of-file indicator for the file with file identifier FID has been set, and 0 otherwise.检测文件指标是否在文件末尾。
ferror Query the MATLAB? software about errors in file input or output
fgetl Read line from file, discarding newline character每次读一行,去掉换行符。
注意:读的是文件句柄!!
fgets Read line from file, keeping newline character每次读一行,保留换行符。
fprintf Write formatted data to file
fread Read binary data from file
frewind Move file position indicator to beginning of open file
fscanf Read formatted data from file