Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
QUAN ZHOU
QUAN ZHOU le 28 Avr 2016
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 commentaire
Mike Quan
Mike Quan le 5 Mai 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!

Connectez-vous pour commenter.

Réponses (1)

Ridouane OULHIQ
Ridouane OULHIQ le 29 Oct 2020
Just don't set the dimension

Catégories

En savoir plus sur Event Functions dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by