ADONIS
Reference Manual
×
Menu
Index
Input-Output Functions
 
Open File:
The following function opens the file filename in the mode specified by permission for reading or writing:
 
Syntax:
fid = fopen(filename,permission)
fid is a scalar integer, called a file identifier. User use the fid as the first argument to other file input/output routines. If fopen cannot open the file, it returns -1. permission can be:
 
"r"
Open file for reading
"w"
Open file, or create new file, for writing; discard existing contents, if any
 
Write Data:
The following function writes data to the text file:
 
Syntax:
fprintf(fid,str)
fid is a scalar integer that has been created by fopen function and str is type string data.
 
Close File:
The following function closes the currently open file:
 
Syntax:
fclose(fid)
fid is a scalar integer that has been created by fopen function.
 
Example:
fileID = fopen("output.txt","w");
fprintf(fileID,"Hello\n");
fprintf(fileID,"Thanks for using ADONIS\n");
fclose(fileID);
 
The help manual was created with Dr.Explain