<< frewind | Stream manager | fseek >> |
R = fscanf(fid, format) |
[R, count] = fscanf(fid, format) |
[R, count] = fscanf(fid, format, sizeR) |
a file descriptor
a string describing the format to used function.
desired dimensions of R.
matrix or character vector.
Read data in text from the file specified by the file descriptor fid.
characters encoding uses fopen parameter.
Value type | format | comment |
---|---|---|
Integer | %i | base 10 |
Integer signed | %d | base 10 |
Integer unsigned | %u | base 10 |
Integer | %o | Octal (base 8) |
Integer | %x | Hexadecimal (lowercase) |
Integer | %X | Hexadecimal (uppercase) |
Floating-point number | %f | Fixed-point notation |
Floating-point number | %e | Exponential notation (lowercase) |
Floating-point number | %E | Exponential notation (uppercase) |
Floating-point number | %g | Exponential notation (compact format, lowercase) |
Floating-point number | %G | Exponential notation (compact format, uppercase) |
Character | %c | Single character |
String | %s | Character vector. |
M = rand(3, 2);
fw = fopen([tempdir, 'example_fscanf.txt'], 'wt');
fprintf(fw, "%f %f %f", M);
fclose(fw);
fd = fopen([tempdir, 'example_fscanf.txt'], 'r');
R = fscanf(fd, "%g %g %g");
fclose(fd);
R
Version | Description |
---|---|
1.0.0 | initial version |
Allan CORNET