StraightLine (FPScript)

21.09.2021

Sets up a straight line equation based on the Y intercept and slope or based on two XY value pairs and evaluates this at the specified X positions.

Syntax

StraightLine(X, b, m)
or
StraightLine(X, Y1, X1, Y2, X2)

 

The syntax of the StraightLine function consists of the following parts:

Part

Description

X

The X values for which the straight line is to be evaluated.

All data structures are allowed. All numeric data types are permitted.

For complex data types the absolute value is formed.

If the argument is a list, then the function is executed for each element of the list and the result is also a list.

b

The Y intercept of the straight line.

Permitted data structures are scalar value. All numeric data types are permitted.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

m

The slope of the straight line. The unit must be compatible for the quotients of the unit of b and X.

Permitted data structures are scalar value. All numeric data types are permitted.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

Y1

The Y value of the first point through which the straight line is to move.

Permitted data structures are scalar value. All numeric data types are permitted.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

X1

The X value of the first point through which the straight line is to move.

Permitted data structures are scalar value. All numeric data types are permitted. The unit has to be compatible with that of parameter X.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

Y2

The Y value of the second point through which the straight line is to move.

Permitted data structures are scalar value. All numeric data types are permitted. The unit has to be compatible with that of parameter Y1.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

X2

The X value of the second point through which the straight line is to move.

Permitted data structures are scalar value. All numeric data types are permitted. The unit has to be compatible with that of parameter X1.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

Remarks

The data type of the result is always 64-bit floating point.

The structure of the result corresponds to that of the argument X. The calculation is done element-by-element where appropriate.

The first variant of the StraightLine function uses the coordinates form of the straight line equation: Y = m*X + b. The second variation calculates the straight line from the two point form: Y = Y1 + (Y2 - Y1) / (X2 - X1) * (X - X1).

For aggregate data structures, only the Y component is considered and the X or, if applicable, Z component is copied into the result without modification.

Available in

FlexPro Basic, Professional, Developer Suite

Examples

Dim x = Series(0 s, 10 s, 1 ms)
Signal(StraightLine(X, -1 V, 3 V/s), X)
 

Generates a straight line with a sampling rate of 1 kHz in the X range from 0 s to 10 s with a Y intercept of -1 V and a gradient of 3 V/s.

Dim x = Series(0 s, 10 s, 1 ms)
Signal(StraightLine(X, -1 V, 0 s, 2 V, 1 s), X)
 

Calculates the straight line from the first example from the two-point form of the straight line equation.

See Also

Chirp Function

Dirichlet Function

Sawtooth Function

Series Function

Square Function

Data Series Operator

Share article or send as email:

You might be interested in these articles