MATLAB: Input/Output dimension error using Mux and Interpreted MATLAB Fcn

blockcontrol systemserrorinterpreted fcnMATLABmuxport dimensionssimulink

Hi there,
I'm having a problem using the Interpreted MATLAB Fcn block. My mux has 4 inputs and (strangely) 2 outputs. I believe this is a backtrace error coming from the Interpreted Fcn block, which I believe is assuming only 2 inputs as well. I don't know why it is behaving like this. I have used this block several times in the past and it always worked well for 2 inputs. This is the first time I'm using more two inputs, so I'm not sure if this block has some kind of limitation in that sense.
I'm attaching the Simulink model, the Matlab function used in the Interpreted Fcn block and the errors I'm getting.
——-Simulink Model:
——– Function used in Interpreted Function block:
——–The error I'm getting when trying to run the simulation
Thanks in advance for your help,
Alessio Silva

Best Answer

Instead of Interpreted Fcn block, you can use the MATLAB function block: https://www.mathworks.com/help/releases/R2020a/simulink/slref/matlabfunction.html which is much flexible to use.