SED navigation bar go to SED home page go to Dataplot home page go to NIST home page SED Home Page SED Staff SED Projects SED Products and Publications Search Dataplot Pages

Dataplot Data Types

No Data Typing Commands You do not need to pre-specify data types. Dataplot automatically determines the correct data type based on usage. In fact, the Dataplot language does not provide any data typing commands. In most cases, you do not need to worry about correct data types.
Data Stored Internally as Single Precision Numbers Dataplot stores numbers internally as single precision floating point numbers. Many internal calculations (e.g., fitting) are performed using double precision arithmetic. However, the results are saved in single precision. On some platforms (e.g., SUN and most Unix workstations), Dataplot can be built in such a way that single precision defaults to double precision. For most applications, this should not be necessary. Contact Alan Heckert if you would like more information about this.
Recognized Data Types Dataplot recognizes the following data types:
  1. Numbers
  2. Parameters
  3. Variables
  4. Strings
  5. Matrices
  6. Complex Numbers

Numbers

Numbers are Unnamed Scalars Numbers are unnamed scalars. They may appear in a variety of different kinds of commands. Note the 20 and 50 in
    BOX 20 20 50 50
Note the 0, 0.1 and 10 in
    PLOT SIN(X) FOR X = 0 0.1 10
Note the 2.5 in
    LET Y = X+2.5
Note the 2 in
    FIT F = A+B*X+C+X**2
General Rule: Parameter Can Be Used In Place of a Number in a Command Line With the exception of the FIT and PRE-FIT commands, the general rule in Dataplot is that anywhere a number appears in a command line, it could equally well have been replaced by a parameter, as in the following analogues to the above:
    LET X1 = 20
    LET Y1 = 20
    LET X2 = 50
    LET Y2 = 50
    BOX X1 Y1 X2 Y2

    LET START = 0
    LET INC = .1
    LET STOP = 10
    PLOT SIN(X) FOR X = START INC STOP

    LET A = 2.5
    LET Y = X+A
Expressions Not Necessarily Interchangeable with Numbers and Parameters However, note that expressions involving numbers and parameters are not necessarily interchangeable with numbers and parameters. For example, the following is NOT valid
    BOX X1+20 Y1-10 X2+5 Y2-3
This should be coded in Dataplot as fullows
    LET X1 = X1+20
    LET Y1 = Y1-10
    LET X2 = X2+5
    LET Y2 = Y2-3
    BOX X1 Y1 X2 Y2
FIT and PRE-FIT Are An Exception The FIT and PRE-FIT commands are an exception because the command lines
    LET D =2
    FIT Y = A+B*X+C*X**D
will not be treated in the same manner as
    FIT Y = A+B*X+C*X**2
In the first case, Dataplot will realize that D is a parameter and so (like all parameters appearing in a fit) will determine the least squares estimate for the parameter D along with the other parameters A, B, and C. However, in the second case (FIT Y = A+B*X+C*X**2), Dataplot will note the scalar number 2 and fit for the parameters A, B, and C only. Be aware of this distinction in carrying out fits and pre-fits.
Numbers Stored Internatlly As Single Precision Floating Point All numbers are stored internally in Dataplot as single precision floating point. If the analyst wishes to specify a decimal number, as in
    LET Y = X*2.378
then the decimal point and trailing decimal digit should of course be included. However, if the number happens to be an integer, then the analyst has the choice of including or excluding the trailing decimal point, and including or excluding any trailing zeros. Thus the following are all equivalent:
    LET Y = X**2
    LET Y = X**2.
    LET Y = X**2.0
    LET Y = X**2.00
All such expressions will be stored and processed internally by Dataplot in an identical fashion. The analyst gains nothing by including the trailing decimal point and zeros. Simplicity dictates that the first form be used, but if the analyst prefers to use other forms, the results will be identical.
Defining Numbers With Large Exponents To define numbers with large exponents (for example, 7.4 raised to the 15th power), the analyst should use the ** (exponentiation) operator directly, as in
    LET A = 7.4**15
The E format (as occurs in FORTRAN) is not permitted; thus
    LET A = 7.4E15
is not a valid Dataplot command.

Negative exponents are handled in a similar fashion, as in

    LET B = 7.4** (-15)
Return to Main Menu

Parameters

Parameters Are Named Scalars A parameter is a named scalar and can be defined via the LET command, as in
    LET A = 27.26
    LET B = 3.97
    LET C = -5.38
    LET D = 2.4*10**(-8)
    LET E = B**2-4*A*C
    LET F = MEAN X
Internally Defined Parameters Two internally-provided parameters which the analyst can use are
    PI
    INFINITY
PI has the value 3.14159265 and INFINITY has the value of the largest floating point number which the user's computer can store (that is, INFINITY = machine infinity). PI and INFINITY can be used at any time and like any other user-defined parameter. For example,
    PLOT (1/SQRT(2*PI))*EXP(-0.5*X**2) FOR X = -3 .1 3
    FIT Y = A+B*X**C EXCEPT X 100 TO INFINITY
Note that a number of Dataplot commands create and save additional parameters automatically. As with PI and INFINITY, these automatically generated parameters can be used anywhere that a user-defined parameter can be used. The command STATUS PARAMETERS will list all currently defined parameters.
Caution When Using Built-In Parameters With FIT Be wary of the use of PI (and other automatically created parameters) in FIT and PRE-FIT expressions; like all parameters, Dataplot will attempt to determine least squares estimates for it. Thus rather than use
    FIT Y = AMP * SIN(2*PI*F*X)
one should use
    FIT F = AMP * SIN(2*^PI*F*X)
The "^" operator substitutes the value of the parameter before the command is parsed by the FIT command. This is equivalent to explicitly entering the value of PI as a number (and it is less likely to result in a typing error).
Parameters Can Be Substituted For Numbers With the exception of the above-mentioned FIT and PRE-FIT exclusion, parameters can be substituted anywhere that numbers appear. For example, suppose the analyst wished to override the usual plot frame coordinates and specify that all succeeding plots have lower left corner at (20,50) and for the plot to be 30 units wide and 30 units high (that is, have the upper right corner at (50,80). This can be done explicitly by
    FRAME CORNER COORDINATES 20 50 50 80
or alternatively
    LET X1 = 20
    LET Y1 = 50
    LET X2 = 50
    LET Y2 = 80
    FRAME CORNER COORDINATES X1 Y1 X2 Y2
or
    LET X1 = 20
    LET Y1 = 50
    LET X2 = X1+30
    LET Y2 = Y1+30
    FRAME CORNER COORDINATES X1 Y1 X2 Y2
Use Of Paramters With The Cross-Hair Command This capability of substituting parameters for numbers is especially convenient for diagram construction on terminals which have bui1t-in hardware for inputting screen coordinates via cross-hair, 1ight-pen, or equivalent. Suppose it is desired to draw a line betveen two points on the screen which the analyst will interactively specify via the cross-hair. One way is to
  • raise the cross-hair (via CROSS-HAIR);
  • position it to the first point (via the thumbwheels or mouse);
  • input and print the coordinates via hitting any key on Tektronix terminals, clicking the appropriate mouse button on X11 terminals, or by hitting some predesignated key on other terminals;
  • raise the cross-hair (via CROSS-HAIR);
  • position it to the second point (via the thumbwheels or mouse);
  • print the coordinates (via hitting the appropriate key as described above);
  • drav the line (via, for example, DRAW 20.4 35.3 78.4 80.5).
An easier way which avoids the handling of absolute numbers and replaces it with the handling of symbolic parameter names is
  • raise the cross-hair (via CROSS-HAIR X1 Y1);
  • position it to the first point (via the thumbwheels or mouse);
  • copy the coordinates into X1 and Y1 (via hitting the appropriate key);
  • raise the cross-hair (via CROSS-HAIR X2 Y2);
  • position it to the second point (via thumbwheels or mouse);
  • copy the coordinates into X2 and Y2 (via hitting the appropriate key);
  • draw the line (via DRAW X1 Y1 X2 Y2).
Return to Main Menu

Variables

Variables Are Named Vectors A variable is a named vector (a named single-dimension array), and can be defined via the LET, READ, SERIAL READ, and DATA commands, as in the following examples
    LET Y = SEQUENCE 1 1 10
    LET Z = PATTERN 1 2 3 FOR I = 1 2 9
    LET U = NORMAL RANDOM NUMBERS FOR I = 1 1 100
    LET X2 = X**2-LOG(Y)
    LET Y2 = SQRT(X+Y**3)
    LET Y = DATA 1 5 10 25 34 46 22 17
or
    READ X Y
    1 1
    2 4
    3 9
    4 16
    5 25
    END OF DATA
or
    SERIAL READ X Y
    1 1 2 4 3 9 4 16 5 25
    END OF DATA
Variables Most Common Component In Dataplot Variables are the most commonly-handled component in Dataplot, as in
    PLOT Y X
    FIT Y = A+B*LOG(X+C)
    LET X2 = LOG(X)
Rules For Variable Names The following are the rules for names (variables, parameters, matrices, functions, and strings) in Dataplot.
  1. Names for variab1es, parameters, matrices, strings, and functions may be of any length, but since only the first eight characters are scanned and internally stored, no two names should be identical for the first eight characters.

  2. Names must start with an alphabetic character, but may be any combination of alphabetic and numeric characters thereafter. It is the author's personal practice to follow the usual mathematical custom of using characters toward the end of the alphabet (X's, Y's, Z's, etc.) to represent variables, of using characters toward the beginning of the alphabet (A's, B's, C's, etc.) to represent parameters, and of using characters in the vicinity of F (e.g., F's, G's, H's, etc.) to represent functions. Note, however, that this is a personal preference and not a Dataplot requirement.
Return to Main Menu

Strings

Dataplot Provides Some Limited String Support Dataplot provides limited support for strings. The most common usage of strings is in labeling plots. Strings can be particularly useful in this regard for reading titles and labels from a file in general purpose macros. Another common usage is building file names in loops. For example, suppose you want to perform the same analysis on the files CALIB1.DAT to CALIB100.DAT. This can be encapsulated in a loop as follows:
    LET STRING BASE = CALIB
    LET STRING EXT = .DAT
    LOOP FOR K = 1 1 100
      LET STRING NUMBER = ^K
      LET STRING FILE = ^BASE&^NUMBER&^EXT
      READ ^FILE X1 TO X10
      ... REST OF ANALYSIS
    END OF LOOP
The "^" And "&" Operators The above loop demonstrates the two operators that Dataplot provides for manipulating and using strings. The ^ character is the Dataplot substitute character. It replaces the succeeding string or parameter with the value of that string or paramaeter. This substitution is done before the command is parsed, so it is very general. The & character is the Dataplot concatenate character. It is used by Dataplot to concatenate two strings together. At this time, Dataplot does not support any functions for extracting a subset of a string.
Commands For Creating Strings There are two commands for creating strings in Dataplot. The READ STRING command is used to read a string from a file. The LET STRING command, demonstrated in the loop above, can also be used. Both of these commands preserve the case of the string as entered (versions of Dataplot prior to 4/96 may convert all characters to upper case for the LET STRING command).
Emulating Arrays Of Strings Dataplot does not currently support arrays of strings. However, this capability can be emulated somewhat with the use of the substitute character (^). For example, suppose you have the 50 state names in a file, one state per line. You can read these into the strings S1 to S50 as follows:
    LOOP FOR K = 1 1 50
      LET NSKIP = K - 1
      SKIP NSKIP
      READ STRING STATES.DAT S^K
    END OF LOOP
The following example shows how to loop through the strings and print them out.
    LET XPOS = 50
    LET YPOS = 97
    LET YINC = 3
    LOOP FOR K = 1 1 50
      MOVE XPOS YPOS
      TEXT ^S^K
      LET YPOS = YPOS - YINC
      IF YPOS < 5
        YPOS = 97
      END OF IF
    END OF LOOP
NOTE: A number of commands for manipulating strings have been added and are documented in the online Dataplot Reference Manual.

Matrices

Matrices Useful For Linear Algebra And Multivariate Analysis Matrices and matrix manipulation commands are useful for solving linear algebra problems. They also find common usage in multivariate statistics. For example, Dataplot provides macros for performing discriminant analysis, canonical correlation, and bi-plots using the matrix commands.

The Dataplot commands that operate on matrices are documented in Chapter 4 of Volume II of the Dataplot Reference Manual.

Matrices cannot be used in Dataplot except for these commands that explicitly require them. Note that the individual columns of a matrix can be used (Dataplot appends the column number to the matrix name).

Commands To Create Matrices Matrices are created with READ MATRIX, CREATE MATRIX, or the MATRIX DEFINITION command. The columns of the matrix can be accessed by appending the column number to the matrix name (e.g., the columns of matrix M can be accessed via M1, M2, etc.). The rows of the matrix cannot be accessed directly. However, the MATRIX ROW command can be used to copy the contents of a matrix row to a column vector. A single element of an array can be extracted with the MATRIX ELEMENT command or by using something like M3(5) (this refers to the element in column 3 and row 5). Matrices cannot be used outside of the commands listed above. For example, you cannot enter LET S = SIN(M) where M is a matrix to compute the sine of all elements in a matrix.
Return to Main Menu

Complex Numbers

Complex Numbers Generally Not Allowed Dataplot operations and built-in functions assume single precision floating point numbers. In general, these cannot be replaced with complex numbers.
Commands That Operate On Complex Numbers The following LET sub-commands specifically operate on complex numbers (the complex numbers are provided as a pair of real numbers):
    COMPLEX ADDITION, COMPLEX CONJUGATE, COMPLEX DIVISION, COMPLEX EXPONENTIATION, COMPLEX MULTIPLICATION, COMPLEX ROOTS, COMPLEX SQUARE ROOT, and COMPLEX SUBTRACTION.
Library Functions That Work With Complex Numbers In addition, a number of built-in library functions can work with complex numbers. These can be somewhat cumbersome since the real and complex component are extracted with distinct functions. For example, to compute the complex sin of a complex number, enter the following 2 commands:
    LET AR = CSIN(-2,1)
    LET AC = CSIN(-2,1)
The parameter AR will contain the real component and the parameter AC will contain the complex component.

The following built-in functions support complex numbers:

  • CABS (complex absolute value),
  • CBESSI (complex modified Bessel function),
  • CBESSJ (complex Bessel function of the first kind),
  • CBESSK (complex modified Bessel function of the third kind),
  • CBESSY (complex Bessel function of the second kind),
  • CCOS (complex cosine),
  • CEXP (complex exponential),
  • CLOG (complex natural logarithm),
  • CSIN (complex sine), and
  • CSQRT (complex square root).
Return to Main Menu

Privacy Policy/Security Notice
Disclaimer | FOIA

NIST is an agency of the U.S. Commerce Department.

Date created: 06/05/2001
Last updated: 09/20/2016

Please email comments on this WWW page to alan.heckert@nist.gov.