How to vectorize signal and parameter?

5 views (last 30 days)
want2know
want2know on 6 Feb 2014
Answered: Kaustubha Govind on 10 Apr 2014
I created a subsystem in Simulink with mask underneath. There are all sorts of control and calculation inside this subsystem. Now I have to duplicate this subsystem for one hundred thousand times because I need to connect one hundred thousands of this block in series.
What I have tried, I used the commands “add_block” and “add_line” where I can just type it in the Matlab command and the blocks and lines are added automatically.
What I wish to do now is, I want to have 100 signals in a single subsystem, so instead of using one hundred thousand subsystem, I will only need one thousand of this subsystem, I understand that this can be done by vectorization.
I have a very limited knowledge on using vectorization feature in Matlab/Simulink. I appreciate if anyone of you could provide me a great reference on how to do this?
What I found here is something like this which I could not link it to my issue above: http://www.mathworks.co.uk/help/matlab/matlab_prog/vectorization.html
The other thing I found is by "using vectorization for most components. Most components are vectorized if they have a vectorized input signal or if one of their parameter is specified as a vector."
However, I could not find any further information/details, appreciate if anyone of you could give opinion on this? Thanks!

Answers (1)

Kaustubha Govind
Kaustubha Govind on 10 Apr 2014
As you found out, most Simulink blocks just accept a vectorized input signal. For instance, if you have a Gain block with a vector as an input, it will simply multiple the Gain parameter value with each element of the vector. What happens if you simply replace a scalar input with a vector input for your subsystem? Note that this may error out depending on the kinds of blocks you use in your subsystem. Another option is to use the For Each Subsystem, so that your subsystem is run once for every element of your input vector.
However, from your question is looks like what you want is to connect the systems in "series"? In which case, you may want to consider the For Iterator Subsystem.

Products

Community Treasure Hunt

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

Start Hunting!