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.
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.
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.
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.