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 and
deployed in Share a Deployable Archive on the Server Instance.
Create a Python MATLAB Production Server client application:
Copy the contents of the
folder
to your development environment.matlabroot
\toolbox\compiler_sdk\mps_clients\python
Open a command line,
Change directories into the folder where you copied the MATLAB Production Server Python client.
Run the following command.
python setup.py install
Start the Python command line interpreter.
Enter the following import statements at the Python command prompt.
import matlab from production_server import client
Open the connection to the MATLAB Production Server instance and initialize the client runtime.
client_obj = client.MWHttpClient("http://localhost:9910")
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]])
Call the deployed MATLAB function.
You must know the following:
Name of the deployed archive
Name of the function
client_obj.addmatrix.addmatrix(a1,a2) matlab.double([[5.0,7.0,9.0],[9.0,7.0,5.0]])
The syntax for invoking a function is client.
. archiveName
.functionName
(arg1
, arg2
,
.., [nargout=numOutArgs
])
Close the client connection.
client_obj.close()