S-function dimension matching problem with lots of "Terminator" blocks
4 views (last 30 days)
Show older comments
Hi All,
I have been using S-function to do the following:
[a1, b1] = choose_cells(c, d);
where a1 and b1 are outputs, c and d are inputs. All the variables are having a single value, except d is an array with 6 values.
Referring to the image attached, we all know that in S-function block, the input dimension must be SAME as output dimension, else we will get error, in this case, the input dimension is 7 while the output dimension is 2, so I have to include the "Terminator" blocks in the diagram for it to work perfectly, otherwise, I will get an error.
My problem is, when the system gets bigger, the array d could contain hundreds of variables, using this method, it means I would have to add hundreds of "Terminator" blocks in order to get this work, this definitely does not sound practical.
Could you please suggest me a wise way to implement this?
Thanks in advance.
0 Comments
Answers (2)
C.J. Harris
on 9 Jul 2013
"we all know that in S-function block, the input dimension must be SAME as output dimension"
I'm really not sure where you get this idea from. It isn't true.
Also, you don't need to use a demux block, you could just use a selector block, with the port dimension being a configurable parameter. That way you could just select the signals you need.
3 Comments
See Also
Categories
Find more on Simulink Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!