- •Is the same as the previous syntax, but accepts attribute value pairs,
- •Xlsfinfo Determine if file contains Microsoft Excel spreadsheet.
- •Internet resource
- •Is a string. Message is either a string or a cell array. If it is a
- •Variables and the Windows registry.
- •Zip file access
- •Individual file can be specified relative to the current directory or
- •Tar file access
- •Individual file can be specified relative to the current directory or
- •Gzip file access
- •Individual file can be specified relative to the current directory or
- •Formatted file I/o
- •Icinterface/fgets
- •If %s is used an element read may cause several matlab matrix
- •Integer NaN as zero.
- •If true, textscan treats
- •File opening and closing
- •It on the matlab search path. On unix systems, filename may also start
- •Binary file I/o
- •If the most recent I/o operation was successful, message is empty
- •Indicator in the specified file. Position is indicated in bytes
- •Memory-mapped file support
- •Is correct for platform it's executed on.
- •Is also a valid partial pathname.
- •Serial port support
- •Instrfind will not find an object with a Name property value of
- •Instrfind will not find an object with a Name property value of
- •Timer support
- •Visible timer objects whose property names and property values match
- •Command window I/o
- •In the current directory. The folder contains an m-file for each web service
Formatted file I/o
<fgetl> - Read line from file, discard newline character.
FGETL Read line from file, discard newline character.
TLINE = FGETL(FID) returns the next line of a file associated with file
identifier FID as a MATLAB string. The line terminator is NOT
included. Use FGETS to get the next line with the line terminator
INCLUDED. If just an end-of-file is encountered, -1 is returned.
If an error occurs while reading from the file, FGETL returns an empty
string. Use FERROR to determine the nature of the error.
MATLAB reads characters using the encoding scheme associated with the
file. See FOPEN for more information.
FGETL is intended for use with files that contain newline characters.
Given a file with no newline characters, FGETL may take a long time to
execute.
Example
fid=fopen('fgetl.m');
while 1
tline = fgetl(fid);
if ~ischar(tline), break, end
disp(tline)
end
fclose(fid);
See also fgets, fopen, ferror.
Overloaded methods:
serial/fgetl
icinterface/fgetl
udp/fgetl
Reference page in Help browser
doc fgetl
<fgets> - Read line from file, keep newline character.
FGETS Read line from file, keeping the newline character.
TLINE = FGETS(FID) returns the next line of a file associated
with file identifier FID as a MATLAB string. The line
terminator is included. Use FGETL to get the next line
WITHOUT the line terminator. If just an end-of-file is
encountered then -1 is returned.
If an error occurs while reading from the file, FGETS returns an empty
string. Use FERROR to determine the nature of the error.
TLINE = FGETS(FID, NCHAR) returns at most NCHAR characters of
the next line. No additional characters are read after the
line terminator(s) or an end-of-file.
MATLAB reads characters using the encoding scheme associated
with the file. See FOPEN for more information.
FGETS is intended for use with files that contain newline characters.
Given a file with no newline characters, FGETS may take a long time to
execute.
See also fgetl, fopen, ferror.
Overloaded methods:
serial/fgets
Icinterface/fgets
udp/fgets
Reference page in Help browser
doc fgets
<fprintf> - Write formatted data to file.
FPRINTF Write formatted data to text file.
FPRINTF(FID, FORMAT, A, ...) applies the FORMAT to all elements of
array A and any additional array arguments in column order, and writes
the data to a text file. FID is an integer file identifier. Obtain
FID from FOPEN, or set it to 1 (for standard output, the screen) or 2
(standard error). FPRINTF uses the encoding scheme specified in the
call to FOPEN.
FPRINTF(FORMAT, A, ...) formats data and displays the results on the
screen.
COUNT = FPRINTF(...) returns the number of bytes that FPRINTF writes.
FORMAT is a string that describes the format of the output fields, and
can include combinations of the following:
* Conversion specifications, which include a % character, a
conversion character (such as d, i, o, u, x, f, e, g, c, or s),
and optional flags, width, and precision fields. For more
details, type "doc fprintf" at the command prompt.
* Literal text to print.
* Escape characacters, including:
\b Backspace '' Single quotation mark
\f Form feed %% Percent character
\n New line \\ Backslash
\r Carriage return \xN Hexadecimal number N
\t Horizontal tab \N Octal number N
For most cases, \n is sufficient for a single line break.
However, if you are creating a file for use with Microsoft
Notepad, specify a combination of \r\n to move to a new line.
Notes:
If you apply an integer or string conversion to a numeric value that
contains a fraction, MATLAB overrides the specified conversion, and
uses %e.
Numeric conversions print only the real component of complex numbers.
Example: Create a text file called exp.txt containing a short table of
the exponential function.
x = 0:.1:1;
y = [x; exp(x)];
fid = fopen('exp.txt','w');
fprintf(fid,'%6.2f %12.8f\n',y);
fclose(fid);
Examine the contents of exp.txt:
type exp.txt
MATLAB returns:
0.00 1.00000000
0.10 1.10517092
...
1.00 2.71828183
See also fopen, fclose, fscanf, fread, fwrite, sprintf, disp.
Overloaded methods:
serial/fprintf
icinterface/fprintf
Reference page in Help browser
doc fprintf
<fscanf> - Read formatted data from file.
FSCANF Read formatted data from file.
[A,COUNT] = FSCANF(FID,FORMAT,SIZE) reads data from the file specified
by file identifier FID, converts it according to the specified FORMAT
string, and returns it in matrix A. COUNT is an optional output
argument that returns the number of elements successfully read.
FID is an integer file identifier obtained from FOPEN.
SIZE is optional; it puts a limit on the number of elements that
can be read from the file; if not specified, the entire file
is considered; if specified, valid entries are:
N read at most N elements into a column vector.
inf read at most to the end of the file.
[M,N] read at most M * N elements filling at least an
M-by-N matrix, in column order. N can be inf, but not M.
If the matrix A results from using character conversions only and
SIZE is not of the form [M,N] then a row vector is returned.
FORMAT is a string containing ordinary characters and/or C language
conversion specifications. Conversion specifications involve the
character %, optional assignment-suppressing asterisk and width
field, and conversion characters d, i, o, u, x, e, f, g, s, c, and
[. . .] (scanset). Complete ANSI C support for these conversion
characters is provided consistent with 'expected' MATLAB behavior.
For a complete conversion character specification, see the Language
Reference Guide or a C manual.