Main Content

Troubleshooting Matrix and Numeric Argument Errors

If a Python® function expects a specific Python multidimensional array type, then MATLAB® displays a message with tips about how to proceed. If the problem might be due to passing a matrix or a multidimensional array as an argument, then do the following.

  1. Check the documentation for the Python function and find out the expected type for the argument.

  2. Create a Python object of that type in MATLAB and pass that to the Python function.

For example, suppose that the following code returns an error.

a = [1 2; 3 4];

If the documentation of pyfunc specifies that the expected type is pyType, then try this conversion:


If the error persists, then determine the root cause by checking for additional information in the Python exception.