saves some Scilab variables in a Matlab MAT-file (binary or ASCII)
savematfile('filename') savematfile('filename', varnames, ...) savematfile('filename', 'var1', 'var2', ...) savematfile filename var1 var2 ... savematfile('filename', '-struct', 's') savematfile('filename', '-struct', 's', 'f1', 'f2', ...) savematfile(..., format)
character string containing the path+name of the file
vector of the names (text) of variables to save, like
["var1" "var2"..]
.
character strings being the names of the variables to save.
data format to use
"-mat" | : binary MAT-file (default) |
"-v4" | : A format that MATLAB Version 4 can open |
"-v6" | : A format that MATLAB Version 6 and earlier can open |
"-v7" | : A format that MATLAB Version 7 and earlier can open (default) |
"-v7.3" | : A format that MATLAB Version 7.3 and earlier can open |
"-ascii" | : 8-bit ASCII format |
"-ascii" "-double" | : 16-bit ASCII format |
"-ascii" "-tabs" | : delimits with tabs |
"-ascii" "-double" "-tabs" | : 16-digit ASCII format, tab delimited |
saves all fields of the scalar structure s as individual variables within the file filename.
saves as individual variables only those structure fields specified (s.f1, s.f2, ...).
Saves some Scilab variables in a Matlab MAT-file. The names of chosen variables may be provided as distinct input arguments, or through a vector of names. By default, all variables existing in the workspace are saved. The Scilab data types are converted into the Matlab equivalents.
![]() |
|
Data type | v4 | v6 | v7 | v7.3 | ASCII | Comments |
---|---|---|---|---|---|---|
boolean | x | bug | bug | bug | x | Bug 15568 |
integer | x | X | X | X | no | int8 are stored as uint8 if they are all > 0, or as int16 otherwise. |
real | x | X | X | X | x | |
complex | x | X | X | X | x | ASCII: imaginary part ignored. |
sparse | x | x | x | x | x | Octave 4.4 loads correctly any real or complex sparse array saved from Scilab 6.0. |
boolean sparse | x | no | no | no | x | v4: Saved as sparse decimal 0|1. Well read from Octave 4.4 |
Text | x | ? | v4: Any array is saved as a column of texts right-padded with spaces to all have the same lengths. | |||
struct | no | x | X | no | ||
cell | no | X | X | X | no | Must not contain components of unsupported type or yielding errors/crashs |
// 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 in v7.3 format: File = TMPDIR+"/savematfile_example.mat"; varnames = ['H','N','I','T','S','C']; savematfile(File,'-v7.3', varnames); clear C H I N S T // Recovering data saved in Matlab format: loadmatfile(File); // Displaying them: for v = varnames, execstr("mprintf(""\n %s ="",v); disp("+v+")"), end | ![]() | ![]() |
--> clear C H I N S T --> // Recovering data saved in Matlab format: --> loadmatfile(File); --> // Displaying them: --> for v = varnames, execstr("mprintf(""\n %s ="",v); disp("+v+")"), end H = (:,:,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 N = 0.2312237 + 0.2146008i 0.8833888 + 0.3616361i 0.3076091 + 0.5664249i 0.2164633 + 0.312642i 0.6525135 + 0.2922267i 0.9329616 + 0.4826472i I = 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 T = !foo ! !bar ! S = num: [2x4x2 constant] imag: [2x3 constant] text: [2x1 string] int: [4x10 int8] C = [ 1x1 string ] [2x3 constant] [2x4x2 constant] [1x1 struct ]
This function has been developed following the "MAT-File Format"
description:
Mat-File Format