How can the Selector Block work with possibly empty indices?

Long time Matlab user, novice Simulink user here...
I've got a signal containing 'n' number of values. Depending on run-time settings based on a Matlab file that calls the Simulink simulation, the signal may contain some combination of signal groups - call them groups A, B, and C. The signal may or may not contain any or all of these different groups. I need to process these three signals differently, then recombine them into the signal in the original order.
I can identify these groups according to an index array that is solved in the Matlab file, and I can filter out the various groups using the Selector block using those index arrays as arguments. I can then recombine the three signals in the desired order after processing them. Here's the problem...
If the signal doesn't contain a group, then the index array for that group is empty, and the Selector block throws an error. I'd prefer it just create an empty signal branch that recombines with the main branch, but I guess that doesn't work.
What is the most efficient way to do this? Help appreciated.

1 commentaire

Prepare two masks signal1_select=[1,1,1,0,0,0,0], signal2_select=[0,0,0,1,1,1,1].
Multiply signals with masks via gains and then add the result via add block.
If no element of a signal is needed, its mask will only contain 0's

Connectez-vous pour commenter.

Réponses (0)

Produits

Version

R2017b

Question posée :

le 18 Oct 2018

Commenté :

le 11 Sep 2025

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by