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”,不知道怎么办

 采纳的回答

hirokit
hirokit 2022-11-26

1 个投票

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

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 User-Defined Functions 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!