Square (FPScript)

21.09.2021

Calculates the square function with a period of 2π, amplitude of 1 and given duty cycle.

Syntax

Square(Angle [ , DutyCycle = 0.5 ])

 

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

Part

Description

Angle

The angle in radians for which you want to calculate the square function.

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.

DutyCycle

A scalar value that specifies the location of the transition from +1 to -1 in the period.

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

The value must be greater or equal to 0 and less or equal to 1.

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.

If this argument is omitted, it will be set to the default value 0.5.

Remarks

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

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

The result has the unit 1, if Angle has a unit. Otherwise, it has no unit.

The function first has the constant value of 1 until it abruptly jumps from 1 to -1 at x = 2π * DutyCycle and then this value is retained until x = 2π. The progression repeats with a period of 2π.

The following illustration shows the course of the function over two periods for different duty cycles:

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(2 V * Square(2 pi * 5 Hz * X), X)
 

Generates a square-wave signal with a sampling rate of 1 kHz in the time range from 0 s to 10 s with an amplitude of 2 V and a frequency of 5 Hz.

See Also

Chirp Function

Dirichlet Function

Sawtooth Function

Sin Function

Straightline Function

Share article or send as email:

You might be interested in these articles