next up previous contents index
Next: The linearize Command Up: Data Manipulation Commands Previous: The fourier Command   Contents   Index


The let Command

The let command is used to assign vectors.

let [vecname [= expr]] [vecname = expr ...]
With no arguments, the list of vectors from the current plot is printed, similar to the display command. If one or more arguments appear without an assignment, information about the named vectors is printed, similar to the display command. Otherwise, for each assignment, if vecname does not exist, a new vector is created with name vecname and value given by the expression expr. An existing vector with the given name will be overwritten with new data.

In WRspice releases prior to 3.0.9, only a single assignment could appear in a let command. In current releases, any number of assignemnts can be given in a single command line. The assignments are performed left-to-right, so that expressions to the right of an assignment may make use of that assignment, i.e., forms like

let a=1 b=a
work properly.

None of the vector options such as default scale, color, etc. that are read from the rawfile are preserved when a vector is created with the let command.

The vecname above can actually be in the plotname.vecname format, where the plotname is the name of a plot or one of the plot aliases as described in 3.16. In this case, only the indicated plot will be searched for a vector named vecname, and if not found, a new vector of that name will be created in the indicated plot.

If no plot is specified, a search for vecname will occur in the current plot, then the context plot if any, and finally the constants plot. If a match is found, that vector will be reused, which may not be what is intended. When a scrpt is run, the current plot at the time the script starts is saved as the ``context plot''. Vectors created in the script before any change in the current plot are saved in the context plot. If the script runs an analysis, the current plot will change, but the previously defined variables will still be available by name as the context plot will be searched as well as the current plot.

If the intention is to use or create a vector in the current plot, the form

let curplot.vecname = expr
should be used, if there is any chance of ambiguity.

The syntax

let a[N] = vec
with N a non-negative integer, is valid. If vec is a vector, then a[N] = vec[0], a[N+1] = vec[1], etc., If undefined, a is defined, and new entries that are not explicitly set are zeroed. The length of a is set or modified to accommodate vec. The syntax a[0] = vec is also valid, and is equivalent to a = vec. If vec is a vector, then a is a copy of vec. If vec is a scalar (unit length vector), then a is also a scalar with the value of vec.

When assignment is from a scalar value, any SPICE number format may be used. That is, if alpha characters appear after a number, the initial characters are checked as a scale factor. Recognized sequences are t, g, k, u, n, p, f, m, meg, mil. Remaining characters are parsed as a units string. This is all case insensitive.

The units suffix of a constant value is used to assign the units of any vector to which the constant is assigned. This means, for example, in

let a = v(1)/15o
a has units of current (A). Use the settype command without arguments to see a list of recognized types.

The ``let'' is actually optional; the let command will be applied to a line with the second token being ``=''. This is somewhat less efficient, however.


next up previous contents index
Next: The linearize Command Up: Data Manipulation Commands Previous: The fourier Command   Contents   Index
Stephen R. Whiteley 2022-09-18