Boost your Octave (for MATLAB users)

Let’s face it, you are using Octave because MATLAB is too expensive for you. Maybe you’re not student anymore and got used to play with MATLAB, but now you need the best free alternative.

Certainly, if money is not a problem, MATLAB would overperform Octave in most of their characteristics (not all of them and I’ll show you) and is surely the best option.

Fear not! GNU Octave is here, and yes, it is indeed the best alternative to MATLAB, but… it’s not the same. We know, and here I present some useful tips to avoid any conflict with your migration to the Octave world.


1. Where’s the IDE?

First of all I know you will miss the nice and elegant IDE of MATLAB. I am sorry to tell you this but you won’t recognize any familiarity to the new MATLAB desktop of the release 2012b. That’s a fancy desktop!

Octave has been normally used with a Command Line Interface, and works nicely, but they also thought about us, mere mortals, who like ornamental environments, and the version 4.0 of Octave was just released with a GUI by default.

What if I have an older version? Not a problem. From version 3.80 and later you can easily start Octave with the beta version of the IDE. Type the following in your command line:

$ octave --force-gui

But just to remind you: it is under constant development and may have several bugs (some of them drive me crazy). The guys are really working hard on it.

You can even drag and drop the widgets of your environment, just like in MATLAB. Yeey!

2. Packages packages!

An annoying thing in MATLAB is the need for extra packages (even for small applications, like convoluting two matrices). But their idea is to offer these extra packages with an extra fee. Pfff!

Well, Octave has also their packages, but naturally for free. First check which packages you have already installed in Octave:

>> pkg list

None? Get ready to get some! Select your prefered package from the List of Octave Packages. Let’s assume you picked the ‘image’ package. There are two ways to install any package.

Online Installation

The easiest way, although you will require an internet connection (if you’re reading this, you probably have it). For our image package it goes:

>> pkg install -forge image
warning: creating installation directory C:\Octave\Octave-4.0.0\share\octave\packages
warning: called from
 install at line 30 column 5
 pkg at line 405 column 9
For information about changes from previous versions of the image package, run 'news image'.
>> pkg list
Package Name  | Version | Installation directory
        image |   2.4.0 | C:\Octave\Octave-4.0.0\share\octave\packages\image-2.4.0


Manual Installation

Download the tar file from the Octave Packages site (you still need internet, duh!) and place it in the working directory, then:

>> pkg install image-2.4.0.tar.gz

Boom! Done. But nothing is perfect in life and there are some packages that actually depend on other packages. Let’s try to install now the ‘mechanics’ package.

>> pkg install -forge mechanics
 error: the following dependencies were unsatisfied:
 mechanics needs linear-algebra >= 2.0.0
 mechanics needs general >= 1.2.2
 mechanics needs geometry >= 1.2.1

Oops! ‘Mechanics’ needs three other packages to work properly (linear-algebra, general and geometry). So you must install those packages first and then install the desired one.

Of course, you can even force the installation without considering its dependencies.

>> pkg install -forge -nodeps mechanics

BUT don’t do it. Avoid problems, unless you have 10 kb left in your hard-drive.

These packages are constantly evolving and sometimes we have to keep track of them so they can work properly. Get the latest changes and news of your packages

>> news image

Try to update your packages as often as possible.

>> pkg update

So, am I ready to use the package? Nope! You have the package in Octave, yes, but you have to load it to your work session to actually use its functions

>> pkg list
Package Name   | Version | Installation directory
        image  |   2.4.0 | C:\Octave\Octave-4.0.0\share\octave\packages\image-2.4.0
>> pkg load image
>> pkg list
Package Name   | Version | Installation directory
        image *|   2.4.0 | C:\Octave\Octave-4.0.0\share\octave\packages\image-2.4.0

Do you see the star next to the package name? It means the package is loaded in your working session. You can also retrieve a list of all the functions of a package for your convenience.

>> pkg describe -verbose image

Have a look at the Octave Package reference of Octave for a better understanding of these great tools.

Tip! If you installed Octave with the Windows Installer, some package tar files are already included. Have a look at the /src directory of your Octave installation.

3. The hidden Symbol

Believe it or not, but Octave also offers symbolic maths. This time it is aided (rarely) by Python and the SymPy. Get it with:

>> pkg install -forge symbolic

Its only dependency would be to have Python and SymPy in your system. Now you can play with beautiful symbolic math:

>> pkg load symbolic
>> x = sym ('x');
   y = sym ('y');
>> poly2sym ({2*y 5 -3}, x)
ans = (sym)

 2*x *y + 5*x - 3

4. The Startup

A handy tool in MATLAB is the startup file. This file is executed every time MATLAB opens, and can be used to include directories to your workspace, load packages, or execute anything you want to do and be ready.

Octave does it too, but its file is called .octaverc and, in Windows, you can find it on:

C:<Octave root directory>\share\octave\site\m\startup

The instructions inside this file will also help you to change your workspace automatically.

5. Compatibility

There is, however, a very dangerous characteristic here. Octave is so good that it allows several notations. It basically allows the same instructions as MATLAB, and adds more capabilities to make it similar to familiar programming languages (like Fortran or C/C++).

But that is also the problem. While it might run nicely in Octave, it can crash in MATLAB, because it does not recognize your code 😦

Have this in mind and try to code with a MATLAB coding style.

6. And Simulink?

Sadly, Octave does not have an alternative for Mathworks Simulink, but you may explore other open source tools like Scilab’s Xcos and OSMC’s OpenModelica. The latest is getting stronger and becoming a standard of free modeling software.

Extra tip!

If you are a freak and still want to compute and play with Octave even when commuting on the train or at the beach (you must be a real freak!) now you can do it with TeleOctave!

TeleOctave is a dedicated service that computes your desires in Octave’s server and returns the results immediately to you if you’re using the messaging App Telegram. Simply add the public username @TeleOctave and play around.

Do you know any other useful trick to ease the migration to Octave? Share it!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s