How to switch from MATLAB to GNU Octave

GNU Octave is a free, open-source numerical computing environment with syntax almost identical to MATLAB’s. Many .m files work unchanged or with few adjustments. It is ideal for matrix computation, university coursework and your own code. What it lacks is Simulink and most specialised toolboxes.

Updated: · 3 min read · How we choose the alternatives

In short

  • Many .m scripts work as they are or with small changes.
  • Octave Forge packages replace some toolboxes.
  • No Simulink or App Designer, and slower in intensive loops.

It’s for you if…

  • Your code mainly uses matrices, numerical functions and plots.
  • You are a student and no longer have a MATLAB licence.
  • You want to keep using your scripts without paying for a licence.

Better pick something else if…

  • You depend on Simulink or specialised toolboxes.
  • Your code needs a lot of speed or uses App Designer: also look at Python or Julia.
Screenshot of GNU Octave
What GNU Octave looks like. Screenshot: Alexander Wilms · CC BY-SA 4.0 · resized

From MATLAB to GNU Octave: equivalents

MATLABGNU Octave
.m files.m files
Command WindowCommand window
ToolboxesOctave Forge packages
.mat files.mat files with save and load
plot and figureplot and figure
MEXmkoctfile --mex
SimulinkNo equivalent: look at Xcos in Scilab
App DesignerNo equivalent

Step by step

  1. Install Octave

    Download it from octave.org. It includes a graphical interface with an editor, command window and variable browser, very similar to MATLAB’s.

  2. Open your project

    Copy your folder and open it in Octave. Add subfolders with addpath if your code needs them.

  3. Run a script

    Start with a simple one and note the errors. They are usually missing functions. Octave has its own syntax, such as # for comments or != for not equal, but it also accepts MATLAB’s.

  4. Install the packages you need

    If a function is missing, find the package and use pkg install -forge followed by its name, for example signal or statistics. Then load it with pkg load name at the start of the script.

  5. Check the results

    Compare with a result you already have from MATLAB. Some functions use different algorithms or default values, and that can change decimals.

  6. Replace what is missing

    For anything that does not exist, write your own version or look for alternatives. For Simulink, you can look at Xcos in Scilab.

Files and formats

Octave runs .m files and reads and saves .mat files with the load and save commands. Use save -v7 if you want the file to open in MATLAB too. Simulink files (.slx) and App Designer apps (.mlapp) do not open. Plots are exported with print to PNG, PDF and SVG.

What you won’t find

Tips

Frequently asked questions

Will my MATLAB code work in Octave?

Often yes, especially code that uses basic numerical functions. Toolboxes and Simulink are the main obstacles.

Does it have the same toolboxes?

No. Octave Forge offers similar packages, such as signal, control or statistics, but not all the functions.

Can it be used for classes?

Yes. It is very common in engineering and science coursework, although check with your teachers whether they require MATLAB.

Independent: we have no commercial relationship, sponsorship or affiliation with MATLAB or with these alternatives, and nobody pays us to recommend them. Links go to their official websites and are not affiliate links; the site is funded only by Google AdSense ads, which don't influence the selection. Learn more.

More guides

See all guides →