Scilab 6.0.2
Please note that the recommended version of Scilab is 2025.0.0. This page might be outdated.
See the recommended documentation of this function
matfile_varreadnext
Reads next variable in a Matlab binary MAT-file.
Syntax
[name, value, vartype] = matfile_varreadnext(fd)
Arguments
- fd
file identifier (integer) as returned by matfile_open.
- name
string: name of the returned variable, or
""
if reading failed.- value
value of the variable read, or [] if reading failed.
- vartype
integer: Matlab type of the variable if reading succeeds, or
- 0: if the variable type is unknown.
- -1: if end of file has been reached.
Description
Reads next variable in a Matlab binary MAT-file opened with matfile_open.
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'); // Reading variables one by one: fd = matfile_open(File, "r", "7.3"); //-- Loop on the stored variables while %t [Name, Value, Type] = matfile_varreadnext(fd); if Type<0 then break else mprintf("The variable ""%s"" has type %d and contains\n", Name, Type); disp(Value); end end matfile_close(fd); sleep(2000) deletefile(File)
--> // Reading variables one by one: --> fd = matfile_open(File, "r", "7.3"); --> //-- Loop on the stored variables --> while %t > [Name, Value, Type] = matfile_varreadnext(fd); > if Type<0 then > break > else > mprintf("The variable ""%s"" has type %d and contains\n", Name, Type); > disp(Value); > end > end The variable "C" has type 1 and contains [ 1x1 string ] [2x3 constant] [2x4x2 constant] [1x1 struct ] The variable "H" has type 6 and contains (:,:,1) 0.2113249 0.0002211 0.6653811 0.8497452 0.7560439 0.3303271 0.6283918 0.685731 (:,:,2) 0.8782165 0.5608486 0.7263507 0.5442573 0.068374 0.6623569 0.1985144 0.2320748 The variable "I" has type 8 and contains 100 51 -52 92 17 34 -94 -30 36 -30 -70 -72 -9 -19 -78 -15 1 -53 -23 91 76 -83 93 -23 63 -80 -69 86 -7 57 25 31 58 -64 -96 -9 -70 -4 -66 -34 The variable "N" has type 6 and contains 0.2312237 + 0.2146008i 0.8833888 + 0.3616361i 0.3076091 + 0.5664249i 0.2164633 + 0.312642i 0.6525135 + 0.2922267i 0.9329616 + 0.4826472i The variable "S" has type 2 and contains num: [2x4x2 constant] imag: [2x3 constant] text: [2x1 string] int: [4x10 int8] The variable "T" has type 4 and contains !foo ! !bar !
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_listvar — Lists variables of a Matlab binary MAT-file.
Bibliography
This function uses MATIO library (
http://sourceforge.net/projects/matio/
).
Report an issue | ||
<< matfile_open | Lecture/Ecriture de fichiers binaires Matlab | matfile_varwrite >> |