Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
5.3.1 - 日本語

Change language to:
English - Français - Português

Please note that the recommended version of Scilab is 2024.0.0. This page might be outdated.
See the recommended documentation of this function

Scilab help >> Files : Input/Output functions > mput

mput

指定したバイナリ形式でバイトまたはワードを書き込む

呼び出し手順

mput(x [,type,fd])

パラメータ

x

浮動小数点数または整数型の数値のベクトル

fd

スカラー. mopen関数により返されたfd パラメータ . デフォルトは -1 で,直近にオープンされたファイルを意味します.

type

文字列. xの全エントリを書き込む際に使用されるバイナリ形式を指定.

説明

mput 関数は, ストリームパラメータ fdで指定した出力先にデータを を書き込みます. データはポインタのカレントの位置に書き込まれ, ポインタのインジケータは前に適当に前に移動されます.

type パラメータは変換指定子で, 以下のフラグ文字(デフォルト値: "l") のどれかに設定されます:

"l","i","s","ul","ui","us","d","f","c","uc"

それぞれ long, int, short, unsigned long, unsigned int, unsigned short, double, float, char, unsigned char を書き込みます. 書き込んだバイトは,(リトルインディアンモードで)マシンに依存するバイナリファイルを 出力するために (リトルインディアンステータスを確認することにより) 必要に応じて自動的にスワップされます. このデフォルトのスワップモードはmopen関数に フラグを追加することにより抑制することができます.

"..l" or "..b"

'l'または'b'文字を型指定子の末尾に追加することにより, リトルインディアンまたはビッグインディアンモードで書き込むことも可能です. 例えば,"db"はビッグインディアンモードでdoubleを書き込みます.

filen = 'test.bin';
mopen(filen,'wb');
mput(1996,'l');mput(1996,'i');mput(1996,'s');mput(98,'c');

// force little-endian 
mput(1996,'ll');mput(1996,'il');mput(1996,'sl');mput(98,'cl');

// force big-endian 
mput(1996,'lb');mput(1996,'ib');mput(1996,'sb');mput(98,'cb');

mclose();
mopen(filen,'rb');
if 1996<>mget(1,'l') then pause,end
if 1996<>mget(1,'i') then pause,end
if 1996<>mget(1,'s') then pause,end
if   98<>mget(1,'c') then pause,end

// リトルインディアンを強制
if 1996<>mget(1,'ll') then pause,end
if 1996<>mget(1,'il') then pause,end
if 1996<>mget(1,'sl') then pause,end
if   98<>mget(1,'cl') then pause,end

// ビッグインディアンを強制
if 1996<>mget(1,'lb') then pause,end
if 1996<>mget(1,'ib') then pause,end
if 1996<>mget(1,'sb') then pause,end
if   98<>mget(1,'cb') then pause,end

mclose();

参照

  • mclose — オープンされているファイルを閉じる
  • meof — ファイルの終端に達したかどうかを確認する
  • mfprintf — 変換,整形し,ファイルにデータを書き込む
  • fprintfMat — 行列をファイルに書き込む .
  • mfscanf — 標準入力から入力を読み込む (C言語の scanf 関数へのインターフェイス)
  • fscanfMat — テキストファイルから行列を読み込む.
  • mget — 指定したバイナリ形式で バイトまたはワードを読み込み, double に変換
  • mgetl — アスキーファイルから行を読み込む
  • mgetstr — 文字列を読み込む
  • mopen — ファイルをオープン
  • mprintf — 変換, 整形し, Scilab主ウインドウにデータを書き込む
  • mputl — アスキーファイルに文字列を書き込む
  • mputstr — ファイルに文字列を書き込む
  • mscanf
  • mseek — バイナリファイルの中でカレントの位置を設定する.
  • mtell — バイナリファイルの管理
  • mdelete — ファイルを削除
<< movefile Files : Input/Output functions mputl >>

Copyright (c) 2022-2023 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Thu Mar 03 11:00:58 CET 2011