Matlab, Linux & Serial Ports

MATLAB on linux follows Ubuntu LTS releases and as such can be quite behind on more recent changes in the linux ecosystem. One recent-ish change that MATLAB still struggles with is the new naming convention for USB-Serial ports. In previous versions of Ubuntu these emulated serial ports were named /dev/ttyUSBX where X is an integer. In newer Ubuntu versions however, these ports are named /dev/ttyACMX, a change that MATLAB has not caught on to yet.

This seemingly small change means that, out-of-the-box, USB-Serial ports will not work at all in MATLAB. The instrhwinfo(‘serial’) command will never see the serial port. Fortunately the fix is quite simple if obscure.

You must create a java.opts file in the same directory as your MATLAB binary with the following contents:

-Dgnu.io.rxtx.SerialPorts=/dev/ttyACM0:/dev/ttyACM1:/dev/ttyACM2

This simply tells MATLAB that serial ports are named ttyACM0, ttyACM1 and ttyACM2.

If you installed MATLAB globally (i.e with sudo) the MATLAB executable should be in /usr/local/MATLAB/R20XXx/bin/glnx64/. This is the directory in which to put the java.opts file. Remember to change the path to point to your specific MATLAB version.

You might also want to check out my post on the first things I do after installing MATLAB on a linux computer here (short version: install matlab-support, fix shortcuts, autosave, date format, default browser & last working folder).

Revision History

2026-01 Add summary end markers to files
2026-01 Migrate to date based urls

Instead of grouping articles by category, we just store them in date order in the content folder.

2025-10 Fix typos and spaces
2017-04 Add `matlab-serial-ports`