Hi Stefano,
The error occurs because your MATLAB function provides the output of a variable-size but, as defined in the Model Explorer, it is of fixed size, or it inherits its size. You can simply take care of this error by checking the "Variable Size" checkbox in the model explorer and specify the upper bound. To do so, open your MATLAB function in the editor, then select EDITOR->Edit data, select output variable, check the variable size checkbox and specify the limit range of your output.
HTH