Connecting a mux to a Matlab 2-Level S-Function with variable sized input dimensions

Hello,
I am developing a custom 2-Level Matlab S-Function for the use in Simulink. I would like to use not a fixed input port dimension, but be able to concatenate signals with a mux block. The resulting signal should then be fed to the 2-Level Function input port, as in the following diagramm.
Unfortunately I stuck at the definitions of the dimensions - if I set the 'DimensionMode' to variable, I get the following error:
Error:Simulink cannot propagate the fixed-size mode from the 'Output Port 1' of 'model/Mux2' to the 'Input Port 1' of 'model/UZ_MonitorInNumeric1'. This input port expects a variable-size mode. Either replace 'model/Mux2' with a block that outputs a variable-size signal or replace 'model/UZ_MonitorInNumeric1' with a block that expects a fixed-size signal.
My definitions in the setup function are:
% Register number of ports
block.NumInputPorts = 1;
block.NumOutputPorts = 0;
% Setup port properties to be inherited or dynamic
block.SetPreCompInpPortInfoToDynamic;
% Override input port properties
block.InputPort(1).DimensionsMode = 'Variable';
block.InputPort(1).Dimensions = [1,10]; %Set Max Dimensions
block.InputPort(1).Complexity = 'Real';
block.InputPort(1).DirectFeedthrough = true;
Is there a way to achieve the desired function within a Matlab 2-Level-S-Function? Thanks in advance!

 Accepted Answer

I figured it out - the dimensions do not have to be specified since the inputPortInfoToDynamic option is set:
% Setup port properties to be inherited or dynamic
block.SetPreCompInpPortInfoToDynamic;
% Override input port properties
%block.InputPort(1).DimensionsMode = 'Variable';
%block.InputPort(1).Dimensions = [1,10]; %Set Max Dimensions
%block.InputPort(1).Dimensions = 3;
block.InputPort(1).Complexity = 'Real';
block.InputPort(1).DirectFeedthrough = true;

More Answers (0)

Categories

Find more on Simulink in Help Center and File Exchange

Products

Release

R2023b

Asked:

on 20 Mar 2024

Edited:

on 20 Mar 2024

Community Treasure Hunt

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

Start Hunting!