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


fscanfMat

テキストファイルから行列を読み込む

呼び出し手順

M = fscanfMat(filename[, fmt]);

[M, text] = fscanfMat(filename [, fmt]);

引数

filename

スキャンするファイルの名前を指定する文字列.

fmt

a character string giving the format. This is an optional parameter, the default value is "%lg".

Supported format: %[width].[precision]type or %type where:

width: optional number that specifies the minimum number of characters output;

precision: optional number that specifies the maximum number of characters printed for all or part of the output field, or the minimum number of digits printed for integer values.

type: lf, lg, d, i, e, f, g (see scanf_conversion).

M

出力変数. 実数の行列.

text

出力変数. 文字列の列ベクトル. ファイルfilenameの先頭のコメントです.

説明

fscanfMat関数はテキストファイルからスカラー行列を読み込むために 使用されます. textが指定された場合,ファイルの先頭の非数値の行が 返されます.残りの行の列の数は同じである必要があります (コロンセパレータは空白文字またはタブ文字であるとみなされます). 行列の列の数はファイルでみつかった列の数となり, 行の数は入力ファイルの終端を検出するまでに取得した行数と なります. この関数はfprintfMatで保存した数値データを 読み戻すために使用することができます.

fscanfMatは,ANSI/ASCII および UTF-8でエンコードされた ファイルをサポートします..

CSV形式のファイルを読み込む場合, csvRead関数の使用が推奨されます.

fd = mopen(TMPDIR + "/Mat", "w");

mfprintf(fd, "Some text.....\n");

mfprintf(fd, "Some text again\n");

a = rand(6,6);

for i = 1:6 ,

for j = 1:6, mfprintf(fd, "%5.2f ", a(i,j));end;

mfprintf(fd, "\n");

end

mclose(fd);

a1 = fscanfMat(TMPDIR + "/Mat")

A = ones(5,5) + 0.1;

fprintfMat(TMPDIR + "/Matrix.txt", A, "%lg");

B = fscanfMat(TMPDIR + "/Matrix.txt", "%lg");

A == B

C = [%nan, %inf, -%inf, 1];

fprintfMat(TMPDIR + "/MatrixNANINF.txt", C);

D = fscanfMat(TMPDIR + '/MatrixNANINF.txt')

参照

  • scanf_conversion — mscanf, msscanf, mfscanf 変換指定子
  • mclose — オープンされているファイルを閉じる
  • meof — ファイルの終端に達したかどうかを確認する
  • mfprintf — converts, formats, and writes data to a file
  • fprintfMat — 行列をファイルに書き込む
  • mfscanf — 標準入力から入力を読み込む (C言語の scanf 関数へのインターフェイス)
  • mget — parses numbers in a binary file and returns them as decimals
  • mgetstr — ファイルから文字列を読み込む
  • mopen — ファイルをオープン
  • mprintf — 変換, 整形し, Scilab主ウインドウにデータを書き込む
  • mput — 指定したバイナリ形式でバイトまたはワードを書き込む
  • mputstr — write a single text in an open file
  • mseek — バイナリファイルの中でカレントの位置を設定する.
  • mtell — ファイル先頭基準でカレントバイトのオフセットを返す
  • mdelete — ファイルを削除
  • csvRead — CSVファイルを読み込む
Report an issue
<< fprintfMat Files : Input/Output functions getmd5 >>

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:
Tue Mar 07 09:28:49 CET 2023