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 function you compiled in Package Deployable Archives with Production Server Compiler App and deployed in Share Deployable Archive (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.