MATLAB: Call poly2trellis in Python

Communications Toolboxmefppython

Hi!
I want to call 'poly2trellis' from Python:
my_trellis = eng.poly2trellis(7, [133, 171])
This results in the following error:
Error using commstr2poly (line 180) Input must be a character vector or a cell of character vectors.
Error in poly2trellis (line 42) cellOutput = commstr2poly(codeGenerator, 'octal');
Thus, I did
function [ trellis ] = get_trellis( )
trellis = poly2trellis(7, [133 171]);
end
It works with all I want to do, but obviously I lost the ability to parameterize it. This is my next approach:
function [ trellis ] = get_trellis( L_C )
trellis = poly2trellis(L_C, [133 171]);
end
This is called in Python with:
eng.get_trellis(7)
And it stops working with:
Error using poly2trellis_mex Input arguments must be nonempty real matrices.
Error in poly2trellis (line 51) trellis = poly2trellis_mex(varargin{:});
Error in get_trellis (line 4) trellis = poly2trellis(L_C, [133 171]);
The same function works if I call it in Matlab directly, but here I need MEfP, so this is not an option. Furthermore, I want to call 'poly2trellis' directly.
Any ideas how to make this work?
Thanks!

Best Answer

You need to use mlArray in order to pass an array to MATLAB from Python. A Python list is converted into a MATLAB Cell array which is not accepted by "poly2trellis". Try this:
>>> eng.poly2trellis(7.0, matlab.double([133,171]))
Reference: