Skip to content
Latchkey

Octave MATLAB incompatibility (function not in Octave) in CI

Octave does not implement every MATLAB function or toolbox. Code that passes on MATLAB can fail on Octave with "undefined" or a parse error because the function, class, or syntax is not available there.

What this error means

The same script that passes on MATLAB fails on Octave with "error: 'X' undefined" or a parse error, where X is a MATLAB function Octave lacks.

Octave
error: 'string' undefined
% MATLAB string() class is not available in this Octave version

Common causes

The function is MATLAB-only

Functions in a MATLAB toolbox, or newer MATLAB features (the string class, some table operations), have no Octave equivalent.

Behavioral or syntax differences

Even shared functions can differ in defaults or accepted syntax between MATLAB and Octave.

How to fix it

Use a compatible implementation

  1. Identify which MATLAB-only feature the error names.
  2. Replace it with an Octave-supported function or a Forge package equivalent.
  3. Guard version-specific code with if exist(...) or isOctave checks.
compat.m
if exist('OCTAVE_VERSION', 'builtin')
  % Octave path
else
  % MATLAB path
end

Install a Forge package that provides it

Some MATLAB functions are provided by Octave Forge packages; install and load the relevant one.

Terminal
octave-cli --eval "pkg install -forge io; pkg load io"

How to prevent it

  • Target the common MATLAB/Octave subset when both must run.
  • Gate engine-specific code behind an OCTAVE_VERSION check.
  • Run the suite on both engines in CI to catch drift early.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →