MATLAB: Does Simulink Test throw indexing errors when the index of a Simulink Selector block specified by an Input Port

objectiveselectorsimulink testtest

I have a Selector block in my model whose index is specified with an Input Port. When I generate and run tests in Simulink Test Manager, I get the following error:
Element 1 of input port <Idx1> in '<model_name>/Selector' has a value of 0. This value is not within the range of permissible values that allows selection of a valid input data element.

Best Answer

The likely cause of the issue is that the Selector block is configured with zero-based indexing. An input port by default takes in a value of zero.
If you require the Index of the selector to be specified by the Input port, you can either use one-based indexing (in the Selector block), or use a test objective block to limit the index inputs within the desired range between 1 and the upper value, as shown in the screenshot below: