Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
5.5.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ヘルプ >> Files : Input/Output functions > fscanfMat

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 — 変換,整形し,ファイルにデータを書き込む
  • fprintfMat — 行列をファイルに書き込む
  • mfscanf — 標準入力から入力を読み込む (C言語の scanf 関数へのインターフェイス)
  • mget — 指定したバイナリ形式で バイトまたはワードを読み込み, double に変換
  • mgetstr — ファイルから文字列を読み込む
  • mopen — ファイルをオープン
  • mprintf — 変換, 整形し, Scilab主ウインドウにデータを書き込む
  • mput — 指定したバイナリ形式でバイトまたはワードを書き込む
  • mputstr — ファイルに文字列を書き込む
  • mseek — バイナリファイルの中でカレントの位置を設定する.
  • mtell — ファイル先頭基準でカレントバイトのオフセットを返す
  • mdelete — ファイルを削除
  • csvRead — CSVファイルを読み込む
Report an issue
<< fprintfMat Files : Input/Output functions getURL >>

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 Oct 02 13:58:25 CEST 2014