MATLAB Coding Guidelines
When writing MATLAB® code for deployment to MATLAB Production Server™ you must adhere to the same guidelines as when writing code for deployment with MATLAB Compiler™ or MATLAB Compiler SDK™. In addition, code deployed to MATLAB Production Server must adhere to additional guidelines:
functions cannot depend on nor change MATLAB state.
Functions deployed with MATLAB Production Server may not always execute on the same instance of the MATLAB Runtime. Each worker access a different MATLAB Runtime instance.
explicitly use
varargin
andvarargout
for functions with variable inputs and outputs.avoid MATLAB figure or GUI code.
Deployed MATLAB code runs on the server, any figures or GUIs created during runtime will show up on the server machine, not the client machine. If figures or GUIs are required to run to create the function results, make sure to close these figures at the end of your code to avoid left over windows and leaking resources on the server.