您的位置:首页 > 编程语言 > MATLAB

fopen user guide in MATLAB

2015-10-21 15:10 477 查看

 

refer to: http://cn.mathworks.com/help/symbolic/mupad_ref/fopen.html
    And: http://cn.mathworks.com/help/matlab/ref/fopen.html
 

Syntax

fopen([code]filename | TempFile
, <
Read | Write | Append
>, <
Bin | Text | Raw
>, <
Encoding = "encodingValue"
>)
[/code]

 

Bin
,
Raw
,
Text


With
Bin
, the data is stored in MuPAD internal binary format. With
Text
, the data may be strings or MuPAD objects stored as text. Newlines are handled according to the conventions of the operating system at hand. With
Raw
,
the data is interpreted as binary machine numbers. See the functions
readbytes
and
writebytes
.

If the mode is
Read
or
Append
, the default is the format of the data in the existing file. If the mode is
Write
, the default is
Bin
.

Encoding


This option lets you specify the character encoding to use. The allowed encodings are:

"Big5"


"ISO-8859-1"


"windows-932"


"EUC-JP"


"ISO-8859-2"


"windows-936"


"GBK"


"ISO-8859-3"


"windows-949"


"KSC_5601"


"ISO-8859-4"


"windows-950"


"Macintosh"


"ISO-8859-9"


"windows-1250"


"Shift_JIS"


"ISO-8859-13"


"windows-1251"


"US-ASCII"


"ISO-8859-15"


"windows-1252"


"UTF-8"


 
"windows-1253"


  
"windows-1254"


  
"windows-1257"


'Big5'


'ISO-8859-1'


'windows-847'


'Big5-HKSCS'


'ISO-8859-2'


'windows-949'


'CP949'


'ISO-8859-3'


'windows-1250'


'EUC-KR'


'ISO-8859-4'


'windows-1251'


'EUC-JP'


'ISO-8859-5'


'windows-1252'


'EUC-TW'


'ISO-8859-6'


'windows-1253'


'GB18030'


'ISO-8859-7'


'windows-1254'


'GB2312'


'ISO-8859-8'


'windows-1255'


'GBK'


'ISO-8859-9'


'windows-1256'


'IBM866'


'ISO-8859-11'


'windows-1257'


'KOI8-R'


'ISO-8859-13'


'windows-1258'


'KOI8-U'


'ISO-8859-15'


'US-ASCII'


 
'Macintosh'


'UTF-8'


 
'Shift_JIS'


 
 

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
. The
Encoding
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):


 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: