refer to: http://cn.mathworks.com/help/symbolic/mupad_ref/fopen.html
And: http://cn.mathworks.com/help/matlab/ref/fopen.html
Syntax
fopen(filename | TempFile
, <Read | Write | Append
>, <Bin | Text | Raw
>, <Encoding = "encodingValue"
>)
| With If the mode is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| This option lets you specify the character encoding to use. The allowed encodings are:
The default encoding is system dependent. If you specify the encoding incorrectly, characters might read incorrectly. Characters unrecognized by the encoding are replaced by the default substitution character for the specified encoding. Encodings not listed here can be specified but might not produce correct results. |
Return Values
a positive integer: the file descriptor. FAIL
is returned if the file cannot be opened.
Example
To specify the encoding to read and write data, use Encoding
. TheEncoding
option applies only to text files that are opened using a file name and not a file descriptor. Create a temporary file and write the string"abcäöü"
in the encoding "UTF-8"
:
fid := fopen(TempFile, Text, Write, Encoding="UTF-8"): file := fname(fid): fprint(Unquoted, fid, "abcäöü"): fclose(fid):