MATLAB Production Server Examples

Server Configuration

Specify the MATLAB Production Server URL. The client will automatically update when you change the URL.

Connection Status

Tests connection to the MATLAB Production Server and lists all available archives using the discovery API.
const client = new MWProdServerClient('https://production-server-demo.mathworks-workshop.com'); const discovery = await client.discover(); console.log('Available archives:', Object.keys(discovery.archives));

Add Matrix Example

Demonstrates adding two matrices using the addmatrix function. This example shows how to pass array inputs and receive numerical results.
const matrix1 = [1, 2, 3]; const matrix2 = [4, 5, 6]; const result = await client.addmatrix_addmatrix(matrix1, matrix2);

Load Forecaster Example

Gets day-ahead energy load forecasts for New York City. This example shows how to handle multiple return values and work with time series data.
const [timestamp, energyload] = await client.LoadForecaster_getDayAheadForecast('N_Y_C_'); // timestamp contains time points // energyload contains corresponding load values

Undiscoverable Function Example

Specify any function path and input arguments to call it directly, even if it's not listed in the discovery API.



// Manually create and call any function const [archive, func] = functionPath.split('/'); const manualFunction = client.createFunction(archive, func, nargout); const result = await manualFunction(...JSON.parse(args));