I have two vector signals with different lenghts in a simulink-model. Now, I want to add the values of the shorter signal to specific elements of the longer one. Let me explain that using an example:
Let’s assume, signal A has the value [1 2 3 4 5], signal B has the value [2 4 8]. I want to add the value of B to the 1st, 3rd and 5th element of A, resulting in [3 2 7 4 13]. The corresponding matlab-command would be A([1 3 5])=A([1 3 5])+B.
The same thing should be possible in Simulink by using the Insert Zero-Block to pad B to the same length as A and then adding both vectors. Unfortunately, this Block requires the Communications System Toolbox which I do not have. Besides using an embedded matlab function, do you see any other possibility?
You can try using a selector block to emulate the indexing in MATLAB, I don’t have Simulink right now, so here’s a powerpoint version of a model. In the selector block, you can either hard code the index you need, or you can feed the index in using a port on the block.
In this case, the model implements,
For more info, see the Selector block documentation.