How to Install GNU Octave and External Packages

How to Install GNU Octave and External Packages
Numerical computations are essential in a lot of industries. Today, machine learning and deep learning are the driving force of different technologies, and mathematical computations help in data processing, before running machine learning or deep learning models on available data.

MATLAB is one of the most popular tools for numerical computations. MATLAB means MatrixLaboratory and is used primarily for numerical computations and symbolic computing.

The downside to MATLAB is that it’s proprietary software and is not a free tool; this discourages a lot of people from using it or forces them to use programming languages for processing.

What is GNU Octave?

GNU Octave is a tool for performing numerical computations just like MATLAB. GNU means “GNU’s Not Unix!”, and GNU software is free of charge.

While there are other software inspired by MATLAB, GNU Octave’s syntax is very similar to that of MATLAB; hence you can use it as a direct replacement for MATLAB.

You should note that Octave is developed to be superior to MATLAB, so it has certain syntax that won’t work on MATLAB. If you can pay for MATLAB, you should go ahead, but if you can’t, you’d do just fine with GNU Octave. Just ensure you stick to MATLAB syntax instead of making use of GNU Octave-only syntax if you intend importing the code into MATLAB environment.

Installation Methods

There are different methods you can use for installing GNU Octave. All methods are relatively easy as they do not require you fiddling with configuration files before installation. Choose that which suits you as they should all work properly.

In this section, you’ll see how you can install GNU Octave through the following methods:

  • FlatPak
  • Ubuntu Software Manager
  • Apt Install

FlatPak

Just like Snaps, FlatPak can be used to quickly install Linux packages. FlatPak is used for software deployment, package management and provides a sandbox for running applications.

Steps for installing GNU Octave through FlatPak:

  1. Ensure you have FlatPak installed. You can check if FlatPak is installed by running the command flatpak –version on the commandline. An error message indicates that FlatPak is not installed yet. Move to step two to install FlatPak, and step three if already installed.
  2. To install FlatPak, you can make use of the apt-get You can install FlatPak with the following command sudo apt-get install flatpak.
  3. Since FlatPak is installed, you need to add the Flathub repository. Flathub is the Appstore for Linux apps, and you’ll be installing GNU Octave from the store. The command flatpak remote-add –if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo is used to add the Flathub repository.
  4. Now that the Flathub repository has been added, you can now install GNU Octave. The command flatpak install flathub org.octave.Octave will be used to install GNU Octave. Note that if the Flathub repository has not been added to the repository list, FlatPak will not find GNU Octave.

Ubuntu Software Manager

The Ubuntu Software Manager can be considered to be the official Appstore for the Ubuntu OS. Installing GNU Octave with the Ubuntu Software Manager is arguably the simplest method on this list.

Steps for installing GNU Octave through the Ubuntu Software Manager:

  1. Launch the Ubuntu Software Manager
  2. Search for GNU Octave
  3. Select the GNU Octave icon in the results
  4. Select “Install”

As you can see, the steps required to install GNU Octave through the Ubuntu Software Manager are very minimal, so you may decide to go with this section.

Apt Install

Asides the options discussed earlier in the article, Octave can also be installed using the apt keyword with the command below:

sudo apt-get install octave

While you should be able to launch Octave by typing in Octave  into the command-line, it may not launch the Graphical User INterface in all cases so you can force it to launch the GUI by adding the commands –force-gui.

This can be seen below:

octave –force-gui
Octave Packages

GNU Octave does come with a lot of built-in features, but these features can be extended using external packages.

In this section, you’ll learn how to install and remove Octave packages. Some of these packages provide extensions for Arduino Microcontrollers, Databases, Fuzzy Logic Toolkit, Image Processing functions, etc.

Before diving into the process of installing Octave packages, you’ll need to install a package on your Debian/Ubuntu machine.

GNU Octave depends on the liboctave-dev package to install external packages.

You can install liboctave-dev with the command below:

sudo apt install liboctave-dev

Installing the Package

To use external packages to extend the functionality of GNU Octave, you need to download the package’s file from the package list.

After download you can run the command below in GNU Octave’s command window to install:

pkg install package-name.tar.gz

For example, after downloading the Image Processing package; it can be installed with the command:

pkg install image-2.10.0.tar.gz

The message displayed after running the command is:

>> pkg install image-2.10.0.tar.gz

For information about changes from previous versions of the image package, run ‘news image’

Loading the Package

After installing your package, you can’t immediately have access to the functions that the package provides; hence you need to load it first.

To load a package, you have to make use of the “load” keyword with the pkg command.

pkg load package-name

You do not have to include the version of the package to use it.

For example, to load the image processing package installed earlier, the command below is used:

pkg load image

The image package should be loaded, and you can access the functions provided by the image package.

Uninstalling the Package

You can uninstall packages just as you installed them; the difference here is that the argument is “uninstall” to remove a package instead of “install” for installing a package.

pkg uninstall package-name

For example, to remove the image processing package you can run:

pkg uninstall image

Conclusion

The installation process of GNU Octave and its packages isn’t complicated. It’s as simple as typing in the commands discussed in this article, and you’re ready to go.

There’s a lot more you can do with GNU Octave packages asides installing, loading and removing, but these simple tasks should be sufficient when working with the tool.

Related Posts
Leave a Reply

Your email address will not be published.Required fields are marked *