More than one output for level-2 S-function
이전 댓글 표시
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
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
Stev
2012년 12월 3일
I have one more question to this topic. In my code i did the definition of the output port like you, but i get the same message like upt0zer0.
I need the OutputSamplingMode th be inherit, but i didn't find how to do this in the matlab help?
Here is my code :
function test(block)
setup(block);
function setup(block)
%%Register number of input and output ports
block.NumInputPorts = 5;
block.NumOutputPorts = 2;
%%Setup functional port properties to dynamically
%%inherited.
block.SetPreCompInpPortInfoToDynamic;
block.SetPreCompOutPortInfoToDynamic;
block.InputPort(1).DirectFeedthrough = true;
%%Set block sample time to inherited
block.SampleTimes = [-1 0];
%%Set the block simStateCompliance to default (i.e., same as a built-in block)
block.SimStateCompliance = 'DefaultSimState';
%%Run accelerator on TLC
block.SetAccelRunOnTLC(true);
%%Register methods
block.RegBlockMethod('Outputs', @Output);
%endfunction
function Output(block)
block.OutputPort(1).Data = block.InputPort(1).Data + block.InputPort(3).Data ;
block.OutputPort(2).Data = block.InputPort(2).Data + block.InputPort(4).Data + block.InputPort(5).Data ;
%endfunction
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
카테고리
도움말 센터 및 File Exchange에서 Configure Block Features for MATLAB S-Functions에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!