HOWTO – Building HTML web apps with MATLAB Production Server

Overview

This guide walks you through turning MATLAB code into a minimal web app that runs on a MATLAB Production Server instance. The process is mostly done within MATLAB, except for the small HTML/JavaScript front‑end, which you can generate with an LLM and then wire up to the server’s RESTful API.


Prerequisites


Step‑by‑Step Workflow

We will use the Patient Health Classification demo for this tutorial.


Example Skeleton (LLM‑Generated)

HTML

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>MATLAB web app</title>
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <h1>My MATLAB Function</h1>
  <div id="output"></div>
  <script src="app.js"></script>
</body>
</html>

JavaScript

// app.js – real call to Production Server
async function runFunction() {
  const payload = {
    rhs: [{
      mwdata: ["my input string"],
      mwsize: [1,1],
      mwtype: "string"
    }],
    nargout: 1,
    outputFormat: {
      mode: "large",
      nanType: "string"
    }
  };

  const response = await fetch('/myCTF/myFunction', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(payload)
  });

  const result = await response.json();
  document.getElementById('output').innerText =
    JSON.stringify(result, null, 2);
}

runFunction();

Replace the mock runFunction logic as needed; an LLM can tailor the payload and response handling to your deployed function’s signature.


Tips & Gotchas


Done!

Your app is now live: the static web page serves the UI, and JavaScript calls the MATLAB function on MATLAB Production Server to display real results.

Feel free to expand the UI, add inputs, or layer in additional functionality. Happy prototyping!