More than one output for level-2 S-function

12 ビュー (過去 30 日間)
upt0zer0
upt0zer0 2012 年 11 月 20 日
コメント済み: Michael Stich 2015 年 11 月 5 日
Hi
i have the following problem. My Level-2 s-function needs a second output.
thats what i've done:
if true
% Register number of ports
block.NumInputPorts = 2;
block.NumOutputPorts = 1;
% Setup port properties to be inherited or dynamic
block.SetPreCompInpPortInfoToDynamic;
block.SetPreCompOutPortInfoToDynamic;
% Override input port properties
block.InputPort(1).Dimensions = [10,1];
block.InputPort(1).DatatypeID = 0; % double
block.InputPort(1).Complexity = 'Complex';
% Override output port properties
block.OutputPort(1).Dimensions = [10,1];
block.OutputPort(1).DatatypeID = 0; % double
block.OutputPort(1).Complexity = 'Complex';
block.OutputPort(2).Dimensions = [5,1];
block.OutputPort(2).DatatypeID = 0; % double
block.OutputPort(2).Complexity = 'Complex';
end
when i start the simulation, always this pops out: "Level-2 MATLAB S-function 'Sync_fehlerkorrektur' in 'Gesamtmodell/Synchronisation' does not have a 'SetInputPortSamplingMode' method. When a Level-2 MATLAB S-function with multiple output ports has dynamic sampling mode setting for any of its ports, it is necessary to register a 'SetInputPortSamplingMode' method"
I searched for this "SetInputPortSamlingMode"-method, but i didn't find anything which helps me.
Can anybody help me? Short explanation and an example plz!
Thx

回答 (1 件)

Kaustubha Govind
Kaustubha Govind 2012 年 11 月 20 日
If need to have two output ports, shouldn't you have:
block.NumOutputPorts = 2; %you've set this to 1
Also, right after you set the output port complexities, also set their sampling mode as the error suggests:
block.OutputPort(1).SamplingMode = 'Sample';
block.OutputPort(2).SamplingMode = 'Sample';
You need to define a SetInputPortSamplingMode method only if you need the output SamplingMode to be inherited.
  3 件のコメント
Kaustubha Govind
Kaustubha Govind 2012 年 12 月 27 日
Stev: If you'd like the output sampling mode to be inherited, you need to implement a SetInputPortSamplingMode method to specify where it's inherited from (you have 5 inputs). Please look at msfuntmpl.m for an example (can be located by typing "which msfuntmpl").
Michael Stich
Michael Stich 2015 年 11 月 5 日
Thank you, this helped figure it out. Little sparse on the details however.
And, why is this SetInputPortSamplingMode method not anywhere to be found in the doc? If it is there I can't find it and I've tried multiple ways of looking. R2015b

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeBlock and Blockset Authoring についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by