MATLAB: Subscripting into an mxArray is not supported.

matlab codermxarray

part of code is:
function m = func_Dec(in)
m = zeros(in(1,1));
n_max = in(1,2);
level = in(1,3);
but errors occur at
Subscripting into an mxArray is not supported.
Function 'func_Dec.m' (#29.405.412), line 16, column 11:
"in(1,1)"

Best Answer

It appears that you are using an extrinsic function (declared with coder.extrinsic) to create in, correct? In that case you need to first assign a value to in before making the extrinsic call to tell the code generation software what type to expect.
For example, suppose that the function foo returns a 3-by-4 array of real doubles. Then you would use code like:
coder.extrinsic('foo');
x = zeros(3,4);
x = foo(y);
You can see my answer:
for more information.