Scilab Home page | Wiki | Bug tracker | Forge | Mailing list archives | ATOMS | File exchange
Please login or create an account
Change language to: English - Português - 日本語

Please note that the recommended version of Scilab is 6.0.0. This page might be outdated.
See the recommended documentation of this function

Aide Scilab >> Entrées/Sorties > save

save

Save a variable or a serie of variables in a binary file

Calling Sequence

save(filename [,x1,x2,...,xn])
save(fd [,x1,x2,...,xn])

Arguments

filename

Character string containing the path of the file

fd

A file descriptor given by a call to mopen

xi

Arbitrary Scilab variable(s)

Description

The save command can be used to save Scilab current variables in a binary file. If a variable is a graphic handle, the save function saves all the corresponding graphics_entities definition.

Since Scilab 5.0, all uimenu or uicontrol handles are also saved by this function.

The file can be given either by its paths or by its descriptor previously given by mopen.

save(filename) saves all current variables in the file defined by filename.

save(fd) saves all current variables in the file defined by the descriptor fd.

save(filename,x,y) or save(fd,x,y) saves only named variables x and y.

Saved variables can be reloaded by the load command.

Note that the written file is portable to other operating systems and architectures (little and big endian).

Examples

a=eye(2,2);b=ones(a);
save('val.dat',a,b);
clear a
clear b
load('val.dat','a','b');

// sequential save into a file
fd=mopen('TMPDIR/foo','wb')
for k=1:4, x=k^2;save(fd,x,k),end
mclose(fd)
fd=mopen('TMPDIR/foo','rb')
for i=1:4, load(fd,'x','k');x,k,end
mclose(fd)

// appending variables to an old save file
fd=mopen('TMPDIR/foo','r+')
mseek(0,fd,'end') 
lst=list(1,2,3)
save(fd,lst)
mclose(fd)

See Also

  • load — Load a saved variable or a serie of variables
  • write — write in a formatted file
  • save_format — format of files produced by "save"
  • mopen — open a file
Scilab Enterprises
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Wed Oct 05 12:11:00 CEST 2011