Last modified: Mon, 06/29/2020 - 14:43
How to use Ferret "constant arrays" (e.g. "{1,3,5}")
Below is an annotated version of the script constant_array_demo.jnl
yes? go /help constant_array_demo ! Description: Demonstration of the {1, 3, 5} "constant array" syntax
Constant arrays allow you quickly to enter lists of constant values.
SYNTAX: Constant arrays are comma-separated lists enclosed in curly braces. If the list needs to contain gaps (missing values), simply omit the element
Example:
yes? LIST {1,3,5}, {1,,5} X: 0.5 to 3.5 Column 1: {1,3,5} Column 2: {1,,5} {1,3,5} {1,,5} 1 / 1: 1.000 1.000 2 / 2: 3.000 .... 3 / 3: 5.000 5.000
Note that a constant variable is always an array oriented in the X direction. To create a constant aray oriented in, say, the Y direction use YSEQUENCE
yes? STAT/BRIEF YSEQUENCE({1,3,5}) Total # of data points: 3 (1*3*1*1*1*1) # flagged as bad data: 0 Minimum value: 1 Maximum value: 5 Mean value: 3 (unweighted average)
Examples:
Below are several examples illustrating uses of constant arrays
Ex 1) plot a triangle
yes? LET xtriangle = {0,.5,1}yes? LET ytriangle = {0,1,0}yes? POLYGON/LINE=8 xtriangle, ytriangle, 0
Ex 2) plot a series of triangles at data points
(See also polymark.jnl for a more automated way to do this: go/help polymark)
yes? LET xpts = 10*RANDU(j[j=1:20]+0) ! random X coordinatesyes? LET ypts = 10*RANDU(j[j=1:20]+1) ! random Y coordinatesyes? LET values = 10* j[j=1:20] ! value at each (x,y) pointyes? POLYGON xpts+xtriangle, ypts+ytriangle, values