Go to the previous, next section.

How should I get data into SM?

Plot vectors may be generated in several ways:

a.
You may read the vectors from a file using the read command The file is expected to be an ASCII file of columns of numbers (separated by spaces or commas). You define the file to SM using the data command, and associate a column or row of numbers with a SM vector using the read command. Example: Say I have a file named test.dat with the following data in it:
1       2       3       5.6     10
3       6       8       2.3     11
5       8       2       7.7     12
7       9       4       9.3     13
9       3       1       4.8     14
Then the commands to issue to SM to get the data into the program are:
        data test.dat
        read x 1
        read y 2
(or read { x 1 y 2 2). In the last 2 commands I have told SM to read the values in column 1 of the file test.dat, and assign them to a vector named x, and read the values in column 2 of the file and assign them to a vector named y. I could read any of the other columns in as well, of course, and assign them to vectors. And I can name the vectors whatever I like, as long as the name consists of the characters a-z,A-Z,0-9, and _ (underscore). I can also read a row from the file, instead of a column, by saying
        read row x 1
Note that the vector is defined by the read command. But I can redefine it whenever I wish, and change the size. The only point to remember is that when you redefine the vector, the old values are overwritten.

A final point to note about defining vectors from files is that you can skip over lines in the file with the lines command. lines defines which lines in the file you want to read. A limitation of lines is that you may only define one set of lines to read; that is, if you had a 30 line file, and wanted to read lines 3-9 and 15-30, you couldn't (well, you could, but you'd have to make clever use of the method of defining vectors which is discussed in the next subsection, or make lines 10-14 each begin with a #).

b.
You may define the vectors within SM using the set command. This command has a number of forms:

c.
You can redefine an existing vector element by element with a do loop:
        set y = 1,50
        ...
        do i=0,100,2 { set y[$i] = $i**2 2
(Note Well that vector elements are numbered starting from 0)

d.
You may create a vector with the spline command. This fits a spline function to a previously defined pair of vectors, and evaluates it at the points given in a third vector, to produce a fourth vector for you.
        set x = 0, 2 * PI, PI/4
        set y = sin(x)
        set xx = 0, 2 * PI, PI/32
        spline x y xx yy
This will fit a spline to the curve y vs x, at the points 0, PI/32, PI/16, 3 * PI/32,... (i.e. the points in the xx vector), and the spline values will be stored in the vector yy.

e.
You may define a vector with the graphics cursor using the cursor command. If you type the command
cursor a b
then a cursor will be displayed on the screen, and to the spline command. This will take a horizontal slice through the image. If you do not give a filename, the vectors are printed to the terminal.

Go to the previous, next section.