Simulink的S​etInputPor​tSamplingM​ode。

报错求助:
Level-2 M-file S-function does not have a 'SetInputPortSamplingMode' method. When a Level-2 M-file S-function with multiple output ports has dynamic sampling mode setting for any of its ports, it is necessary to register a 'SetInputPortSamplingMode' method.
但是,我看Template文件里也没有这个所谓的“SetInputPortSamplingMode”,不知道怎么办

 Accepted Answer

hirokit
hirokit on 26 Nov 2022
block.RegBlockMethod('SetInputPortSamplingMode',@SetInputPortSamplingMode);
block.RegBlockMethod('SetInputPortDimensions', @SetInpPortDims);
block.RegBlockMethod('Outputs', @Output);
function SetInputPortSamplingMode(block, idx, fd)
block.InputPort(idx).SamplingMode = fd;
block.InputPort(idx).SamplingMode = fd;
block.OutputPort(1).SamplingMode = fd;
block.OutputPort(2).SamplingMode = fd;
function SetInpPortDims(block, idx, di)
block.InputPort(idx).Dimensions = di;
function Output(block)
block.OutputPort(1).Data = block.InputPort(1).Data;
block.OutputPort(2).Data = block.InputPort(2).Data;
是个callback function

More Answers (0)

Categories

Tags

Asked:

on 26 Nov 2022

Answered:

on 26 Nov 2022

Community Treasure Hunt

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

Start Hunting!