a4c26d1e5885305701be709a3d33442f.png

http://hi.baidu.com/ocnzhao/item/a165cabcdddfbc422bebe340

function level2S(block)

%

Level-2 MATLAB file S-Function for continuous time variable step

demo.

% Copyright 1990-2009 The

MathWorks, Inc.

% $Revision: 1.1.6.2

$

setup(block);

%endfunction

setup(block);

function setup(block)

% Register number of ports and parameters

block.NumInputPorts = 1;

block.NumOutputPorts = 1;

% block.NumDialogPrms = 1;

% Setup functional port properties to dynamically

inherited

block.SetPreCompInpPortInfoToDynamic;

block.SetPreCompOutPortInfoToDynamic;

% Register the properties of the input port

block.InputPort(1).Complexity = 'Inherited';

block.InputPort(1).DataTypeId = -1;

block.InputPort(1).SamplingMode = 'Sample';

block.InputPort(1).DimensionsMode = 'Fixed';

block.InputPort(1).DirectFeedthrough = true;

% Register the properties of the output port

block.OutputPort(1).DimensionsMode = 'Variable';

block.OutputPort(1).SamplingMode = 'Sample';

% Register sample times

% [-1, 0] : Inherited sample

time

block.SampleTimes = [-1 0];

% Register methods called during update

diagram/compilation

block.RegBlockMethod('SetInputPortDimensions', @SetInputPortDims);

block.RegBlockMethod('PostPropagationSetup', @DoPostPropSetup);

% Register methods called at run-time

block.RegBlockMethod('Outputs', @Outputs);

%

-------------------------------------------------------------------------

% function SetInputDimsMode(block, port, dm)

% % Set dimension mode

% block.InputPort(port).DimensionsMode = 1;

%

-------------------------------------------------------------------------

function SetInputPortDims(block, idx, di)

width = prod(di);

if width ~= 1

DAStudio.error('Simulink:blocks:multirateInvaliDimension');

end

% Set compiled dimensions

block.InputPort(idx).Dimensions = di;

block.OutputPort(idx).Dimensions =[5 5];%constant,and larger than

used.

%

-------------------------------------------------------------------------

function DoPostPropSetup(block)

% Set the type of signal size to be dependent on input values,

i.e.,

% dimensions have to be updated at output

block.SignalSizesComputeType =

'FromInputValueAndSize';

%

-------------------------------------------------------------------------

function Outputs(block)

% Output function:

% -update output values

% -update signal dimensions

block.OutputPort(1).CurrentDimensions =

[block.InputPort(1).Data,block.InputPort(1).Data];

block.OutputPort(1).Data

=magic(block.InputPort(1).Data);

%endfunction

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐