필터 지우기
필터 지우기

inherit dimension of multiple input port in a Level-2 S-Function

조회 수: 2 (최근 30일)
QUAN ZHOU
QUAN ZHOU 2016년 4월 28일
답변: Ridouane OULHIQ 2020년 10월 29일
I'm using a QP solver (qpas.mex) in Simulink that requires a Level-2 S-Function block. However, I have trouble to specify the dimension of each input port. Here is the setup
function mySFcn(block)
setup(block);
function setup(block)
nInPorts = 2;
block.NumInputPorts = nInPorts;
block.NumOutputPorts = 1;
for i = 1 : nInPorts
block.InputPort(i).Dimensions = -1;
block.InputPort(i).DatatypeID = 0; % double
block.InputPort(i).Complexity = 'Inherited';
block.InputPort(i).DirectFeedthrough = true;
block.InputPort(i).SamplingMode = 'Inherited';
end
block.OutputPort(1).Dimensions = -1;
block.OutputPort(1).DatatypeID = 0; % double
block.OutputPort(1).Complexity = 'Inherited';
block.NumDialogPrms = 0;
block.SampleTimes = [-1 0];
block.SimStateCompliance = 'DefaultSimState';
block.RegBlockMethod('Outputs', @Outputs); % Required
block.RegBlockMethod('Terminate', @Terminate); % Required
function Outputs(block)
W = block.InputPort(1).Data; % 12 x 12, e.g.
tau = block.InputPort(2).Data; % 3 x 1, e.g.
block.OutputPort(1).Data = qpas(W,tau); % e.g.
function Terminate(block)
I always get an error message that states a 12x12 matrix cannot get into my s-function block through port 1. Anybody know how to correct this error? By the way, each port will have different dimension, and I have no way to know the dimension.
  댓글 수: 1
Mike Quan
Mike Quan 2017년 5월 5일
Hello Mr Quan,
I have a similiar problem, where the dimension of the biggest input matrix somehow determines the dimensions for any other inut AND output.
Also I tried making input/output sizing inherited by
block.SetPreCompInpPortInfoToDynamic;
block.SetPreCompOutPortInfoToDynamic;
without success! Please tell, if you find a solution!

댓글을 달려면 로그인하십시오.

답변 (1개)

Ridouane OULHIQ
Ridouane OULHIQ 2020년 10월 29일
Just don't set the dimension

카테고리

Help CenterFile Exchange에서 Block and Blockset Authoring에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by