S-function documentation that "S-function level-1 supports vector inputs and outputs. DOES NOT support multiple input and output ports".

2 Ansichten (letzte 30 Tage)
Dear Sir/Madam,
I read in S-function documentation that "S-function level-1 supports vector inputs and outputs. DOES NOT support multiple input and output ports".
Does the second sentence mean the input and output dimension MUST BE SAME?
I have been using S-function level-1 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.

Antworten (1)

Kaustubha Govind
Kaustubha Govind am 16 Jul. 2013
Is there a reason that you would not like to upgrade to Level-2 S-functions? Level-1 S-functions have been deprecated for several years and only exist for the sake of backwards compatibility.
Since Level-1 S-functions have been deprecated, I can't find documentation on how you can configure the size of the output to not be the same as the size of the input (I'm not sure if it's even possible). I would recommend that you convert your Level-1 S-function to Level-2, so you can configure the dimensions of the input and output appropriately, using block.InputPort(1).Dimensions and block.OutputPort(1).Dimensions.
  2 Kommentare
want2know
want2know am 16 Jul. 2013
Bearbeitet: want2know am 16 Jul. 2013
Hi Kaustubha,
Thanks for your reply, actually I have been trying to convert my level-1 S-function to level-2 but I got stuck at calling another subfunction at function Output(block) trying to look for other threads but to no avail, do you mind to provide related links?
My output depends on a lot processing with the inputs, this is the reason I need to call the sub-function in order to calculate and then return output values, all the examples that I can see are calculating their outputs directly in "function Output(block)", in my case I thought it is not possible.
I then tried to use Interpreted Matlab Function block but failed due to the output dimension is NOT the same as input dimension, also it does not support the return of more than ONE output................
yuge sun
yuge sun am 3 Nov. 2020
Dont use level-2 function, u will regret for its running speed. Level-2 function has low speed and still has lots of problem which doesnt suitable for user to develop block friendly.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Simulink Functions finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by