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

1 次查看(过去 30 天)
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.

回答(1 个)

Kaustubha Govind
Kaustubha Govind 2013-7-16
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 个评论
want2know
want2know 2013-7-16
编辑:want2know 2013-7-16
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 2020-11-3
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by