This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Troubleshooting Multidimensional Array 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];
py.pyfunc(a)

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

py.pyfunc(pyType(a))

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