fopen user guide in MATLAB

来源:互联网 发布:五矿证券软件下载 编辑:程序博客网 时间:2024/06/07 22:03

 

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">)

 

Bin, Raw, Text

With Bin, the data is stored in MuPAD internal binary format. WithText, the data may be strings or MuPAD objects stored as text. Newlines are handled according to the conventions of the operating system at hand. WithRaw, the data is interpreted as binary machine numbers. See the functionsreadbytes andwritebytes.

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

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

 

0 0
原创粉丝点击