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 versionCommon 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
- Identify which MATLAB-only feature the error names.
- Replace it with an Octave-supported function or a Forge package equivalent.
- Guard version-specific code with
if exist(...)orisOctavechecks.
compat.m
if exist('OCTAVE_VERSION', 'builtin')
% Octave path
else
% MATLAB path
endInstall 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_VERSIONcheck. - Run the suite on both engines in CI to catch drift early.
Related guides
Octave "parse error" in CIFix Octave "parse error" in CI - a syntax construct Octave rejects, often MATLAB syntax that Octave does not…
Octave "error: 'X' undefined" in CIFix Octave "error: 'X' undefined" in CI - the name is not on the Octave path (addpath missing), belongs to an…
Octave "package X is not installed" (pkg load) in CIFix Octave "error: package X is not installed" in CI - pkg load needs the package installed first with pkg in…