kalkuel,
That error you are getting might have to do with the array that you are passing out of the s-function.
The workspace that the s-function works in and the one for the simulink simulation are different.
I would check what variable type you are passing out of the s-function and how many signals it is being broken into.
When you said multiplexing do you mean passing the signals to a mux before passing them in to the s-function?
Not knowing what our model looks like in the location of the error makes it difficult to give a direct answer.
BSK