S-function dimension matching problem with lots of "Terminator" blocks

3 visualizzazioni (ultimi 30 giorni)
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.

Risposte (2)

C.J. Harris
C.J. Harris il 9 Lug 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 Commenti
want2know
want2know il 9 Lug 2013
Modificato: want2know il 9 Lug 2013
With regard to the statement "we all know that in S-function block, the input dimension must be SAME as output dimension", I did try many times and Simulink keeps giving me the error message that "Invalid setting for input port dimensions of 'Demux'. The dimensions are being set to 10. This is not valid because the total number of input and output elements are not the same"
That explains why I have this kind of misconception.
I found this unanswered thread with similar issue http://www.mathworks.co.uk/matlabcentral/newsreader/view_thread/255825
want2know
want2know il 9 Lug 2013
Modificato: want2know il 9 Lug 2013
I tried again the approach of using Bus selector where a1 and b1 are outputs, c and d are inputs, I could not get it worked, reason being, my understanding is unless the desired output is the one or all of the inputs, else there is no way of using Bus selector in my case, am I right?
As shown in this Matlab documentation http://www.mathworks.co.uk/help/simulink/examples/simulink-bus-signals.html, there are FIVE inputs to BUS CREATOR (chirp, constant, clock, pulse, sine), the BUS SELECTOR selects TWO out of these FIVE parameters, in my case, a1 and b1 are not in BUS CREATOR, so can I still use bus selector (which I doubt)? Please correct me if I am wrong. I am willing to learn.

Accedi per commentare.


want2know
want2know il 12 Lug 2013
Is it that the only way to solve this problem is to convert the current level-1 S-function to level-2 S-function?

Community Treasure Hunt

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

Start Hunting!

Translated by