Skip to main content
U.S. flag

An official website of the United States government

Official websites use .gov
A .gov website belongs to an official government organization in the United States.

Secure .gov websites use HTTPS
A lock ( ) or https:// means you’ve safely connected to the .gov website. Share sensitive information only on official, secure websites.

d. Loops

The measurement states of an experiment are generated using loops. Loops are defined using lists, ranges, and expressions.

In our example, a range and an expression are used (see the Reference for more on Lists) in a loop to define the measurement states that the experiment will have.

Loop Example

A range is a compact way to specify a series of measurement states from a set of parameters.

Range Example

In our example, the range will cause motorA to visit positions: 1.0, 2.0, 3.0, 4.0, and 5.0.   

An expression is a list of values for the trajectory to visit that is generated by a formula relying on lists, ranges, and other expressions.

Expression Example

In our example, the expression will cause motorB to visit positions: 2.0, 4.0, 6.0, 8.0, and 10.0. This is because motorA visits positions 1.0, 2.0, 3.0, 4.0, and 5.0 and motorB visits every position of motorA multiplied by two.

Note: Expressions should not be the only thing within a loop, because they depend on other values.  However, they can reference variables in outer loops - more on this later.

Created December 6, 2018, Updated December 12, 2018