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. Please click here
To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

Create a Python Client

This example shows how to write a MATLAB® Production Server™ client using the Python® client API. The client application calls the addmatrix function you compiled in Create a Deployable Archive for MATLAB Production Server (MATLAB Production Server) and deployed in Share a Deployable Archive on the Server Instance (MATLAB Production Server).

Create a Python MATLAB Production Server client application:

  1. Copy the contents of the matlabroot\toolbox\compiler_sdk\mps_clients\python folder to your development environment.

  2. Open a command line,

  3. Change directories into the folder where you copied the MATLAB Production Server Python client.

  4. Run the following command.

    python install
  5. Start the Python command line interpreter.

  6. Enter the following import statements at the Python command prompt.

    import matlab
    from production_server import client
  7. Open the connection to the MATLAB Production Server instance and initialize the client runtime.

    client_obj = client.MWHttpClient("http://localhost:9910")
  8. Create the MATLAB data to input to the function.

    a1 = matlab.double([[1,2,3],[3,2,1]])
    a2 = matlab.double([[4,5,6],[6,5,4]])
  9. Call the deployed MATLAB function.

    You must know the following:

    • Name of the deployed archive

    • Name of the function


    The syntax for invoking a function is client.archiveName.functionName(arg1, arg2, .., [nargout=numOutArgs]).

  10. Close the client connection.

Was this topic helpful?