MATLAB Function Interface Error

I have a MATLAB function block that has two inputs and one output. One input is a column vector with values for calculations and is a variable size. The other input is a bus signal with a fixed size. The output is another column vector that is a variable size. I have checked all the ports (both in the model explorer and the ports and data manager, which I think should show the same thing as far as the ports go) on the input blocks, the function block, and the output block. From what I can tell they all are set to the proper mode (i.e. variable or fixed) but I am still getting the following error:
MATLAB Function Interface Error: Unable to propagate the variable-size mode from the input 'SimulinkReactor' of 'SimulinkReactor'. This input expects a fixed-size mode. The variable-size mode originates from 'SimulinkMATLAB Function Block/MATLAB Function Block/ SFunction '. Examine the configurations of 'MATLAB Function Block' for one of the following scenarios: 1. The block does not support variable-size signals 2. The block supports variable-size signals but needs to be configured for them. You can enable variable-sizing for 'MATLAB Function Block' from the ports and data manager dialog.
Any ideas what I could be missing?

Answers (2)

Kaustubha Govind
Kaustubha Govind on 9 Nov 2011
It looks like the error is about the output of the MATLAB Function block. Have you configured it as a variable-size signal and specified the maximum dimensions correctly? See this page for an example. It looks like you also need to use the coder.varsize directive to specify that the output is of variable-size.

7 Comments

I've checked the ports and they are all set to variable size. I've use the command "coder.varsize" from the link you provided to declare all variables passed through those ports as variable size. The vector I'm trying to pass is a column vector and the variable size block is checked and the size is set to [100 1]. As I understand it the size you set is just the max that variable can be.
Unfortunately I'm still getting the same error. Any other ideas?
One of my input ports is variable size and one is fixed. I use both in the calculations for the output port. Could that have anything to do with it?
What do you have connected to the variable-sized output of the MATLAB Function block? Perhaps it only accepts fixed-size signals? Try using an output port block just to test this hypothesis - this block should be able to handle any type of signal.
Now I'm getting this error:
Size of variableName cannot be modified as the variable variableName is already locked.
Dimension 1 cannot be made dynamic: it has previously been set to have fixed size 200.
Function 'MATLAB Function Block' (#25.370.382), line 8, column 15:
"'variableName'"
I have set the size to be [200 1] in the ports and data manager because I read that when you check the variable size check block you also have to set a maximum size. Is that not correct?
Yes, you do need to set the upper bound for the size - but have you also checked the "Variable size" checkbox?
Yes, I have checked the "Variable Size" check box. You were right. It is the block I am sending the signal to. I need to send the signal to an integrator block. Is there a block that will convert the signal?
There is no way to convert a variable-size signal to a fixed-size signal, because that doesn't make sense - how would you convert a signal that varies size during simulation to one that doesn't? Perhaps you should rewrite your MATLAB Function block code to emit fixed-size signals if that's what makes sense for your application. You can always use the maximum size at all times, and fill in the invalid elements with zero (or some invalid value) if you really want to simulate a variable-size signal.

Sign in to comment.

imran Hossain
imran Hossain on 5 Feb 2012
i have same problem with the interface error in simulink block. i create the 16-apsk modulation and demodulation block using matlab code. when i run this individual block there is no error but when i put this block other existing 16-qam or psk it shows "MATLAB Function Interface Error: Simulation stopped due to out of bounds error. Block MATLAB Function1 (#19) While executing: none ". anybody if have some idea or logic, i would like to request please share with necessary information.

1 Comment

did u sort the problem out?I have to write the apsk modulation code and demodulation code too.Can you help in writing the code for modulation and demodualtion

Sign in to comment.

Categories

Find more on Test Model Components in Help Center and File Exchange

Products

Asked:

Jon
on 9 Nov 2011

Commented:

on 15 Apr 2015

Community Treasure Hunt

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

Start Hunting!