The Modelit Embedded Webserver Toolbox (MEWT) is the successor of the Modelit Webserver Toolbox (MWT) for Matlab. The latter has been around since 2008. Compared to MWT, MEWT is easier to install, easier to use, more versatile and designed for Docker deployment.

The Embedded Webserver Toolbox has been developed for Matlab developers who seek to deploy their algorithms to the web without leaving the Matlab ecosystem and without paying additional royalties.

With MEWT, launching a Matlab based web/HTTP server  is as easy as issuing the command:


where myFunction can be any function that accepts an object of class modelit.web.client.HttpRequest as its first input argument. The methods of this class are used to extract data that is sent to http://localhost:4444 using GET or POST methods.

Live example

To give a quick impression of the capabilities of the Modelit Embedded Webserver  for Matlab we have prepared a number of illustrative examples that run 24/7 on our server. The examples can be verified in a browser. The page Live Examples shows the source code of the examples and the URLs for verification. 

White paper

We have recently published an informative white paper on MEWT. See Alternative approach to implementing HTTP webservices based on Matlab code

Use cases

The table below shows a number of use cases for the MEWT :

Client Server Example
Browser Matlab session  running MEWT. Input parameters are passed as name-value pairs in the HTTP GET string. Output is HTML code that is generated on the fly.

Website Front End running in Browser. Typically created with a javascript framework. Matlab session  running MEWT. The communication between front and back-end  typically consists of JSON messages.

With this website the impact of motorway speed enforcement  on the number of accidents is analyzed. The front-end of the site is coded in JavaScript/Angular. The back-end is coded in Matlab.

Matlab session invoking the MEWT remoteFunction utility.

Matlab session  running MEWT.  This is where MEWT really shines. The toolbox takes full advantage of the Matlab native methods to serialize data to establish compressed and lossless data exchange between client and server. Moreover with 1 line of code  it lets users convert any function to a version that executes remotely. 

Server side:

Client side:
  [a,b] = fp_client(10:-1:1 )

  MEWT server features

Feature Description
Support for multiple contexts While running a single server, one can make separate server side functions available at different URL paths. Fore example invokes callback htmlCallback at context /html, and invokes callback jsonCallback at context /json. 
Password protection For each context, access to the server can be restricted by requiring a username and password to be specified by the client.
SSL support Traffic between client and server can be SSL encrypted. This requires a server side certificate. The MEWT  includes a utility generateSelfSignedCertificate.m for creating a self signed certificate that can be used for testing purposes.
Built in support for Matlab clients

Although  modelit.web.server.Server can be combined with any client, doing so requires that one has to decide on what data exchange format to use and implement this for the server and the client.

If the client is a Matlab process things can be simplified to a great extent. MEWT comes with two utilities: remoteCallback and remoteFunction.

remoteCallback returns a Matlab function that can be used to specify the callback for modelit.web.server.Server.

remoteFunction returns a Matlab function that can be used as any other Matlab function, but executes remotely.

This illustrated in an example:

%Server side:
fp_server = remoteCallback({'sort','version'});
%Client side: 
fp_sort = remoteFunction('http://localhost:4444',@sort)        %Note: 'sort' would have been acceptable as well
fp_version = remoteFunction('http://localhost:4444',@version) 
[a,b] = fp_client(10:-1:1 ) 
[v,d] = fp_version()

 In this way, a Service Oriented Architecture can be implemented without leaving the Matlab ecosystem, and without needing a deep understanding of HTTP.

Built in Queue While the server is processing a request of client #1, client #2 might send a new request. If this happens, the new request will be appended to the queue. The server will continue processing requests untill the queue is empty. Currentlty failover is not yet implemented. If heavy loads are expected, it is recommended to run multiple instances of modelit.web.server.Server in parallel and divide incoming requests over these instances using load balance software such as NGINX.  We have described the procedure how to do this in the document Deploying Matlab applications with Docker
Royalty free What you need to run the Modelit Embedded Webserver for Matlab is a Matlab License a copy of MEWT. With this you can deploy MEWT servers on all machines for which your Matlab License is valid. If you have access to Matlab Compiler you can run MEWT in compiled mode on as many machines as you need without paying additional royaltees.
Ready for docker deployment The Modelit Embedded Webserver Toolbox (MEWT) succeeds the Modelit Webserver Toolbox (MWT) for Matlab and has been fully redesigned. An important reason for this has been the requirement that software can be deployed in Docker containers. We have prepared a step by step guide that explains how to run a compiled  Matlab Webservice in Docker and how to scale it using the NGINX load balancer.
Live debugging Debugging Webservices can be tricky and time consuming. Wit MEWT, you can set breakpoints in the Matlab callback function that is called from modelit.web.server.Server and if you have access to the MEWT source code you will be able to trace your webserver code step by step. This will enable you to view what is happening in background while using the front end.
Compatible with Matlab compiler All functions in the MEWT can be compiled with the Matlab Compiler
Tested on Windows and Linux MEWT has been tested on Windows and Linux machines

MEWT Overview

The MEWT programming interface is described in an API that doubles as online help. When the MEWT toolbox is on the Matlab path, the "doc" command shows the MEWT help information under "Supplemental Software". The MEWT functionality is implemented by 5 Matlab classes.  If used 

 Server Side Classes
 Use these to implement server side behavior

 Client Side Classes
 Use these to implement client side behavior

 modelit.web.server.Server  modelit.web.client.HttpRequest
 modelit.web.server.HttpExchange  modelit.web.client.HttpResponse

Free version

A fully functional free version can be downloaded from this link:

Go to download page

In this version all code except the examples is obfuscated using Matlab pcode. The download is a zip file with m-code,  p-code, jarfiles and html help. 

Obtaining a commercial license

The difference between the commercial and the free version is that the commercial version contains no p-code. This allows you to inspect every last detail of the code, do small tweaks, and prevents you from running into problems when using the Matlab compiler.  When you purchase a commercial license, we will also be able to support you if and when needed. 

Read all about Pricing and Ordering

Send us your feedback

We at Modelit are very much interested in your feedback! If you have any questions or remarks, please send us an email.