Main Content

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 MATLAB function deployed to a server instance. For information on writing and compiling the function for deployment, see Create Deployable Archive for MATLAB Production Server (MATLAB Production Server). For deploying the function to the server, see Deploy Archive to MATLAB Production Server (MATLAB Production Server).

Before you write the client application, you must have the MATLAB Production Server Python client libraries installed on your system. For details, see Install the MATLAB Production Server Python Client (MATLAB Production Server).

  1. Start the Python command line interpreter.

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

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

    client_obj = client.MWHttpClient("http://localhost:9910")
  4. 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]])
  5. 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]).


    The output is:


  6. Close the client connection.


See Also

(MATLAB Production Server)

Related Topics