matfile_listvar
Lists variables of a Matlab binary MAT-file.
Syntax
[names, classes, types] = matfile_listvar(fd)
Arguments
- fd
file identifier (integer) as returned by matfile_open.
- names
column of strings: names of the variables stored in the file.
- types
column of integers: Matlab data type of the variables.
- classes
column of integers: Matlab class of the variables.
Type name Matlab class Matlab type Scilab type/inttype cell 1 21 17 struct 2 22 17 text 4 10 sparse 5 5 double real|complex 6 9 1 single real|complex 7 7 NA int8 8 1 8/1 uint8 9 2 8/11 int16 10 3 8/2 uint16 11 4 8/12 int32 12 5 8/4 uint32 13 6 8/14 int64 14 12 8/8 uint64 15 13 8/18
Description
Lists variables of a Matlab binary MAT-file opened with matfile_open.
Returns empty matrices if the file contains no variables.
Examples
// Preparing some data: H = rand(2,4,2); N = complex(rand(2,3), rand(2,3)); I = int8(grand(4,10,"uin",-100,100)); T = ["foo" "bar"]'; S = struct("num",H, "imag",N, "text",T, "int",I); C = {"Scilab", rand(2,3); H, S}; // Saving them: File = TMPDIR+"/matfile_listvar_example.mat"; savematfile(File,'-v7.3', 'H','N','I','T','S','C'); // Listing stored variables: fd = matfile_open(File); [names, classes, types] = matfile_listvar(fd); matfile_close(fd); sleep(1000) deletefile(File); names', classes', types' mprintf("The variable ""%s"" has type %d and class %d\n", names, types, classes)
--> names', classes', types' ans = !C H I N S T ! ans = 1. 6. 8. 6. 2. 4. ans = 21. 9. 1. 9. 22. 2. --> mprintf("The variable ""%s"" has type %d and class %d\n", names, types, classes) The variable "C" has type 21 and class 1 The variable "H" has type 9 and class 6 The variable "I" has type 1 and class 8 The variable "N" has type 9 and class 6 The variable "S" has type 22 and class 2 The variable "T" has type 2 and class 4
See also
- matfile_open — Opens a Matlab binary MAT-file.
- matfile_close — Closes a Matlab binary MAT-file.
- matfile_varwrite — Write a variable in a Matlab binary MAT-file.
- matfile_varreadnext — Reads next variable in a Matlab binary MAT-file.
Bibliography
This function uses the external MATIO library (
http://sourceforge.net/projects/matio/
).
Report an issue | ||
<< matfile_close | Matlab : fichiers données (R/W) | matfile_open >> |