1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
read(1) Scilab Function read(1)
NAME
read - matrices read
CALLING SEQUENCE
[x]=read(file-desc,m,n,[format])
[x]=read(file-desc,m,n,k,format)
PARAMETERS
file-desc : character string specifying the file name or integer value
specifying logical unit (see file).
m, n : integers (dimensions of the matrix x). Set m=-1 if you do not
know the numbers of rows, so the whole file is read.
format : character string, specifies a "Fortran" format. This
character string must begin with a right parenthesis and end with
a left parenthesis. Formats cannot mix floating point or charac-
ter edition modes.
k : integer or vector of integer
DESCRIPTION
reads row after row the mxn matrix x (n=1 for character chain) in the file
file-desc (string or integer). Each row of the matrix x begin in a new
line of file-desc file. Depending on format, a given row of the x matrix
may be read from more than one line of file-desc file.
The type of the result will depend on the specified format. If format con-
tains only (d,e,f,g) descriptors the function tries to read numerical data
(the result is matrix of real numbers).
If format contains only a descriptors the function tries to read character
strings (the result is a character string column vector). In this case n
must be equal to 1.
Examples for format:
(1x,e10.3,5x,3(f3.0))
(10x,a20)
When format is omitted datas are read using numerical free format:
blank, comma and slash may be used as data separators, n*v may be use
to represent n occurrences of value n.
A direct access file can be used if using the parameter k which is
is the vector of record numbers to be read (one record per row),
thus m must be m=prod(size(k)).
To read on the keyboard use read(%io(1),...).
EXAMPLE
unix('rm -f foo')
A=rand(3,5); write('foo',A);
B=read('foo',3,5)
B=read('foo',-1,5)
read(%io(1),1,1,'(a)') // waits for user's input
SEE ALSO
file, readb, write, x_dialog, scanf
|