server

Server to be running on network machine.

Must be running for client to be able to connect. Obviously, alongside this server, MATLAB should also be running.

class mr_utils.matlab.server.MATLAB[source]

Object on server allowing server to communicate with MATLAB instance.

done_token

Sequence of symbols to let us know MATLAB is done communicating.

Type:contract.done_token
process

Process that runs MATLAB and stays open.

Type:subprocess
catch_output(log_func=None)[source]

Grab the output of MATLAB on the server.

Parameters:log_func (callable, optional) – Function to use to log output of MATLAB console.
exit()[source]

Send exit command to MATLAB.

get(varnames)[source]

Get variables from MATLAB workspace into python as numpy arrays.

Parameters:varnames (list) – List of names of variables in MATLAB workspace to get.
Returns:tmp_filename – Name of temporary file where MATLAB workspace contents are stored.
Return type:str
Raises:ValueError – When varnames is not a list type object.

Notes

Notice that varnames should be a list of strings.

put(tmp_filename)[source]

Put variables from python into MATLAB workspace.

Parameters:tmp_filename (str) – MAT file holding variables to inject into workspace.
run(cmd, log_func=None)[source]

Run MATLAB command in subprocess.

Parameters:
  • cmd (str) – Command to send to MATLAB console.
  • log_func (callable, optional) – Function to use to log output of MATLAB console.
class mr_utils.matlab.server.MyTCPHandler(request, client_address, server)[source]

Create the server, binding to localhost on port.

what

The action we wish to perform.

Type:{contract.RUN, contract.GET, contract.PUT}
cmd

The command to be run in the MATLAB console.

Type:str
rfile

Stream from TCP socket that we are reading from.

Type:stream
mr_utils.matlab.server.start_server()[source]

Start the server so the client can connect.

Notes

This server must be running on the remote before client can be used to connect to it.

Examples

To run this server, simply run:

python3 mr_utils/matlab/start_server.py