A custom level-2 Simulink routine generates thsi error: "unknown frame status for its output port 1". I want "sample" output, not frame. I am not using DSP. I've tried many options for 2 hours. error persists

조회 수: 7 (최근 30일)
Here's my setup code, including commented-out code of things I've already tried. I apologize that this blog removes all carriage returns. STOP=carriage return. STOP function setup(block) STOP nModelNodes = 162; % Number of model nodes. "assignin" to the workspace STOP block.NumInputPorts = 2; % 1st: data vector; 2nd: clock STOP block.NumOutputPorts = 1; % To save data to the workspace STOP block.SetPreCompInpPortInfoToDynamic; STOP block.SetPreCompOutPortInfoToDynamic; STOP %block.SetPreCompPortInfoToDefaults; STOP % Initialize the compiled information (dimensions, data type, complexity, STOP % and sampling mode) of the block's ports to the default values. STOP % By default, a port accepts a real scalar sampled signal STOP % with a data type of double. STOP % Override input port properties STOP block.InputPort(1).Dimensions = 3*3*nModelNodes; % xyz * Position, velocity, acceleration STOP block.InputPort(2).Dimensions = 1; STOP %block.OutputPort(1).IsSampleHit = true; % True STOP block.OutputPort(1).SampleTime = 0.002; % double STOP block.OutputPort(1).Dimensions = (3*3*nModelNodes+1); % Vector STOP % block.OutputPort(1).DirectFeedthrough = true; % Error message when trying to set this. STOP % Register parameters STOP block.NumDialogPrms = 0; STOP block.SampleTimes = [0 0]; STOP block.SimStateCompliance = 'DefaultSimState'; STOP block.RegBlockMethod('PostPropagationSetup', @DoPostPropSetup); STOP block.RegBlockMethod('InitializeConditions', @InitializeConditions); STOP block.RegBlockMethod('SetInputPortSamplingMode', @SetInpPortFrameData); STOP block.RegBlockMethod('Start', @Start); STOP block.RegBlockMethod('Update', @Update); STOP block.RegBlockMethod('Outputs', @Outputs); % Required STOP block.RegBlockMethod('Terminate', @Terminate); % Required STOP block.NumContStates = 0; STOP %end setup

답변 (1개)

Darshan Ramakant Bhat
Darshan Ramakant Bhat 2017년 12월 19일
There is a bug in Simulink 6.1 (R14SP1) if you are using it, when using a level 2 MATLAB file S-function with more than one output port.
To work around this issue, you need to explicitly declare that these output ports are sample-based rather than frame-based in the MATLAB file setup function. To do this, add the following lines of code to your setup function for each output port after the "block.SetPreCompOutPortInfoToDynamic" command in the setup function, if it exists:
block.OutputPort(1).SamplingMode = 'Sample'; ... block.OutputPort(n).SamplingMode = 'Sample';

카테고리

Help CenterFile Exchange에서 Signal Generation에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by