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


listvarinfile

保存されたデータファイルの中の変数の一覧を得る

呼び出し手順

listvarinfile(filename);
[names, typs, dims, vols] = listvarinfile(filename)

引数

filename

文字列, 調べるファイルのパス名

nams

文字列の行列, ファイルに保存した変数の名前

dims

リスト, ファイルに保存した変数の次元

typs

数値行列, ファイルに保存した変数の型

vols

数値行列, ファイルに保存した変数の大きさ(単位:バイト)

説明

このユーティリティ関数は, saveにより作成されたScilabデータファイルに含まれる 変数の一覧 "a la whos" を取得します.

有理数および状態空間はプレーンな tlist として報告されます.

// Preparing some data of various types:
b = rand(2,3) < 0.5;                    // booleans
i = uint64(grand(3,4,2,"uin",0,100));   // hypermatrix of encoded integers
c = grand(3,3,"uin",-10,10); c=c+c'*%i; // complex numbers
p = (1-%z).^(0:3);                      // polynomials
r = p/(1+%z);                           // rationals
sp = sprand(10,15,0.1);                 // sparse numbers
spb = sp<0.5;                           // sparse booleans
t = ["This" "software" ; "is" "Scilab"];// Texts
g = [gdf() gda()];                      // Graphics
function Test()                         // macro
    disp("listvarinfile() test for macros")
end
M = linspace;                           // macro
L = list(%f, int8(-23),, %i-%z, list("abc",%e)); // simple list
C = {"abc" %t ; %z list(1/%z, 4)};      // array of cells
S(4,2).r = %pi;                         // array of structures
vars = list("b","i","c","p","r","sp","spb","t","g","Test","M","L","C","S");

// Archiving data in a binary file:
File = TMPDIR + "\listvarinfile.sod";
save(File, vars(:))

// Listing the file content:
[names,types,dims,vols] = listvarinfile(File);
types(find(names=="Test"))
dims(find(names=="i"))
--> [names,types,dims,vols] = listvarinfile(File);
Name                     Type           Size            Bytes
-------------------------------------------------------------
C                        cell           2 by 2          76
L                        list           4               51
M                        macro          1 by 1          0
S                        struct         4 by 2          8
Test                     macro          1 by 1          0
b                        boolean        2 by 3          24
c                        double         3 by 3          144
g                        handle         1 by 2          0
i                        integer        3 by 4 by 2     192
p                        polynomial     1 by 4          80
r                        tlist          4               162
sp                       sparse         10 by 15        232
spb                      boolean sparse 10 by 15        624
t                        string         2 by 2          40

--> types(find(names=="Test"))
 ans  =
   13.

--> dims(find(names=="i"))
 ans  =
   3.   4.   2.

参照

  • save — Saves some chosen variables in a binary data file
  • load — Loads some archived variables, a saved graphic figure, a library of functions
  • save_format — "save"で作成されるファイルの形式
  • type — 変数の型を返す
  • whos — 長い形式で変数のリストを得る
  • who — 変数の一覧

履歴

バージョン記述
6.0
  • Hypermatrices are now listed with the type of their content, instead of "mlist" and type 17. Their sizes are now the actual ones, instead of 3.
  • Cells and Structures arrays now appear as "cell" and "struct" instead of "mlist". Their sizes are now the actual ones, instead of 3.
  • Arrays of graphic handles now appear as "handle" and type 9, instead of "tlist" and type 16. Their sizes are now the actual ones, instead of 3.
  • Macros now appear as "macro" and type 13, instead of "tlist" and type 16.
  • Real and complex numbers now appear as "double" instead of "constant".
Report an issue
<< %io Files : Input/Output functions mclearerr >>

Copyright (c) 2022-2024 (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