Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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 Commento
Mike Quan
Mike Quan il 5 Mag 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!

Accedi per commentare.

Risposte (1)

Ridouane OULHIQ
Ridouane OULHIQ il 29 Ott 2020
Just don't set the dimension

Categorie

Scopri di più su Event Functions in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by