Main Content

Using an External Function in a Test Sequence Block

This example shows how to call an externally-defined function from the Test Sequence block. The provided function, Attenuate.m, is defined in a script on the MATLAB® path and is called from the test sequence. The Attenuate.m function is:

function[y] = Attenuate(x)

y = 0.65*x;

end

Open the TestSeqOutputFunctions model

model = 'TestSeqOutputFunctions';
open_system(model)

Test Sequence Output Functions model

Open the Test Sequence block

In the model, double-click the Test Sequence block, Calling ext functions. The ReducedSine step in the Test Sequence block uses the external function, Attenuate, to reduce the amplitude of the signal sg.

The Test Sequence editor displays the steps in the Test Sequence block. There are three steps named Initialize, ReducedSine, and Stop.

Simulate the model

Simulate the model and view the output signal sg and attenuated signal asg in the Scope2 block.

sim(model)
open_system([model '/Scope2'])

See Also

Topics