Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
QUAN ZHOU
QUAN ZHOU el 28 de Abr. de 2016
Respondida: Ridouane OULHIQ el 29 de Oct. de 2020
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 comentario
Mike Quan
Mike Quan el 5 de Mayo de 2017
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!

Iniciar sesión para comentar.

Respuestas (1)

Ridouane OULHIQ
Ridouane OULHIQ el 29 de Oct. de 2020
Just don't set the dimension

Categorías

Más información sobre Event Functions en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by