Documentation

Generate Function-Based Test Signals

The Test Sequence block uses MATLAB® as the action language. You can use functions to generate signal outputs to the component under test.

  1. Define an output data symbol in the Data Symbols pane.

  2. Use the output name with a signal generation function in the test step action.

In this test sequence, the step Sine outputs a sine wave with a period of 10 seconds, specified by the argument et*2*pi/10. The step Random outputs a random number in the interval -0.5 to 0.5.

You can also define a function in a script on the MATLAB path, and call the function in the Test Sequence block. In this test sequence, the ReducedSine step reduces SignalOut using the function Attenuate.

function[y] = Attenuate(x)
y = 0.65*x;
end

Output Functions

Generate test signals using output functions. Some output functions use the temporal operator et, which is the elapsed time of the test step in seconds.

Note

Function outputs are not constrained to provide a defined pattern. Scaling, rounding, and other approximations of argument values can affect function outputs.

Common output functions include:

FunctionSyntaxDescriptionExample
squaresquare(x)

Represents a square wave output with a period of 1 and range –1 to 1.

Within the interval 0 <= x < 1, square(x) returns the value 1 for 0 <= x < 0.5and –1 for 0.5 <= x < 1.

Output a square wave with a period of 10 sec:

square(et/10)
sawtoothsawtooth(x)

Represents a sawtooth wave output with a period of 1 and range –1 to 1.

Within the interval 0 <= x < 1, sawtooth(x) increases.

Output a sawtooth wave with a period of 10 sec:

sawtooth(et/10)
triangletriangle(x)

Represents a triangle wave output with a period of 1 and range –1 to 1.

Within the interval 0 <= x < 0.5, triangle(x) increases.

Output a triangle wave with a period of 10 sec:

triangle(et/10)
rampramp(x)

Represents a ramp signal of slope 1, returning the value of the ramp at time x.

ramp(et) effectively returns the elapsed time of the test step.

Ramp one unit for every 5 seconds of test step elapsed time:

ramp(et/5)
heavisideheaviside(x)

Represents a heaviside step signal, returning 0 for x < 0 and 1 for x >= 0.

Output a heaviside signal after 5 seconds:

heaviside(et-5)
latchlatch(x)

Saves the value of x at the first time latch(x) evaluates in a test step, and subsequently returns the saved value of x. Resets the saved value of x when the step exits. Reevaluates latch(x) when the step is next active.

Latch b to the value of torque:

b = latch(torque)
sinsin(x)

Returns the sine of x, where x is in radians.

A sine wave with a period of 10 sec:

sin(et*2*pi/10)
coscos(x)

Returns the cosine of x, where x is in radians.

A cosine wave with a period of 10 sec:

cos(et*2*pi/10)
randrand

Uniformly distributed pseudorandom number.

Generate values from the uniform distribution on the interval [a, b].

a + (b-a)*rand
randnrandn

Normally distributed pseudorandom number.

Generate values from a normal distribution with mean 1 and standard deviation 2.

1 + 2*randn(100,1)
expexp(x)

Returns the natural exponential function, ex.

An exponential signal progressing at one tenth of the test step elapsed time:

exp(et/10)

See Also

|

Related Topics

Was this topic helpful?