I guess, there might be a bug inside the embedded function. Did you make sure that the matrix-vector operations are all correct? For example, multiply [4x4] x [4x1] rather than the other way around?
Can you share your code as an attachment to your question and the error msg ?
See for example the sample model and code below.

The function looks like this:
function y = fcn(a,b)
x = a*b;
y = dot(x,x);
