Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2023.0.0 - Русский


writes real numbers or strings in the console or in a formatted file


write(file_desc, a)
write(file_desc, a, format)
write(file_desc, a, k, format)




  • a character string specifying the file name. Trying to overwrite an existing file will yield an error.
  • or the integer id of a file opened with file(…) (see file). Using %io(2) will write in the console.

This function can not open a UTF filename. In this case, please uses mopen.


Matrix of real numbers, or column of character strings.


character string specifying a "Fortran" format. It must begin with a left parenthesis and end with a right one. The format must be about only one type of input data. It can't mix placeholders for real numbers and for strings.

Format examples : "(1x,e10.3,5x,3(f3.0),1x,i4)" , "(10x,a20)".

"x": white space. "5x" = 5 white spaces
"a": string. "a20" = 20 first characters of the input string.
"i": print as integer
"f": real number
"e": real number in exponential form.
"(…)": group. 3(…) = iterate 3 times the group.
Please see a Fortran book for more information.


integer vector


writes row-by-row a real matrix or a column vector of character strings in a formatted file. Each row of the a argument begin in a new line of file_desc file. Depending on format a given row of the a argument may be written in more than one line of file_desc file.

Direct access files : x=write(file_desc,a,k,format). Here k is the vector of records (one record by row, i.e. m=prod(size(k))

write(%io(2),....) writes on Scilab's console. Note that in this case format should produce one output line per matrix row. If this constraint is not verified, unpredictable behavior could happen.


if getos() == 'Windows' then unix('del asave');
else unix('rm -f asave'); end
A = rand(5,3);
A = read('asave',5,3);

write(%io(2),A,'('' | '',3(f10.3,'' | ''))')

if getos() == 'Windows' then unix('del foo');
else unix('rm -f foo'); end

See also

  • save — Saves some chosen variables in a binary data file
  • writb — fortran file binary write
  • file — управление файлами
  • fileinfo — предоставляет информацию о файле
  • print — prints variables in a file
  • mfprintf — преобразует, форматирует и записывает данные в файл
  • mprintf — converts, formats, and writes data to the main scilab window
  • fprintfMat — записывает матрицу в файл
Report an issue
<< writb Input/Output functions write4b >>

Copyright (c) 2022-2023 (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:48 CET 2023