More than one output for level-2 S-function
12 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
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
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
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 Exchange 中查找有关 Block and Blockset Authoring 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!