Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Octave signal package installation

I'm on Ubuntu 16.04 and currently using Octave as a reciprocal to Matlab for signal processing. Everything was fine till I needed to use medfilt1 function to get the median. Octave generated an error report saying that signal package is not installed on my system. After browsing a bit I found the command

 sudo apt-get install octave-signal

I ran this command and it showed everything downloaded and installed perfectly. However, if I again run the octave script the error persists:

warning: the 'medfilt1' function belongs to the signal package from Octave Forge which you have installed but not loaded. To load the package, run 'pkg load signal' from the Octave prompt.

Please read http://www.octave.org/missing.html to learn how you can contribute missing functionality. warning: called from unimplemented at line 524 column 5 filter-practice.m at line 8 column 2 error: 'medfilt1' undefined near line 8 column 3 error: called from filter-practice.m at line 8 column 2

Analyzing the error message I attempted to run pkg load signal but the terminal told me that there is no such command.

command not found: pkg

How can I get the signal package installed on my system?

like image 410
Bishwajit Purkaystha Avatar asked Apr 16 '17 05:04

Bishwajit Purkaystha


People also ask

What is Octave in signal?

In electronics, an octave (symbol: oct) is a logarithmic unit for ratios between frequencies, with one octave corresponding to a doubling of frequency. For example, the frequency one octave above 40 Hz is 80 Hz. The term is derived from the Western musical scale where an octave is a doubling in frequency.

How do I upgrade my Octave?

You can find the installation files for Windows by going to the Octave download page and clicking 'Windows'. There will be several file options there. Most people choose the first one (octave-5.1. 0-w64-installer.exe) for 64bit systems.


1 Answers

I'll provide an answer here for future users, even though the post has an accepted answer already, as it's missing all the relevant details (if you're only interested in how to make a package installed via apt-get to show up on your octave session, see the bit at the end).

To install one of the packages listed on Octaveforge (see here for the full list of available packages), you can download the .tar.gz file for the particular package from its respective page (e.g. here for the signal package), and then go to that folder and issue the following command at an octave terminal:

pkg install signal

Alternatively and far more conveniently, you can ask octave to download the package directly from Octaveforge and install it, by appending the -forge option:

pkg install signal -forge

You may also want to specify where to install such packages if you don't like the default location (typically ~/octave), using the pkg prefix command before installing a package (see documentation for details).

Once a package has been installed, you can query the list of installed packages using the pkg list command; 'loaded' packages are noted with an asterisk, e.g on my PC.

octave:1> pkg list
Package Name         | Version | Installation directory
---------------------+---------+-----------------------
fuzzy-logic-toolkit  |   0.4.5 | /media/tasos/Gandalf/opt/octave-4.2.1/lib/fuzzy-logic-toolkit-0.4.5
              image *|   2.6.1 | /media/tasos/Gandalf/opt/octave-4.2.1/lib/image-2.6.1
                 io  |   2.4.7 | /media/tasos/Gandalf/opt/octave-4.2.1/lib/io-2.4.7
         statistics  |   1.3.0 | /media/tasos/Gandalf/opt/octave-4.2.1/lib/statistics-1.3.0

To load a package, use the pkg load command; any 'dependencies' will be loaded as well automatically, e.g.:

octave:2> pkg load statistics
octave:3> pkg list
Package Name         | Version | Installation directory
---------------------+---------+-----------------------
fuzzy-logic-toolkit  |   0.4.5 | /media/tasos/Gandalf/opt/octave-4.2.1/lib/fuzzy-logic-toolkit-0.4.5
              image *|   2.6.1 | /media/tasos/Gandalf/opt/octave-4.2.1/lib/image-2.6.1
                 io *|   2.4.7 | /media/tasos/Gandalf/opt/octave-4.2.1/lib/io-2.4.7
         statistics *|   1.3.0 | /media/tasos/Gandalf/opt/octave-4.2.1/lib/statistics-1.3.0

The above methods are all considered local installations. Octave keeps a list of installed packages in files called octave_packages, typically found either in your octave installation or your home folder. In the case that you've installed packages globally from a repository instead you will have to let octave know by linking to the appropriate octave_packages file, typically /usr/share/octave/octave_packages, using the pkg global_list command.

For example, I had to install the odepkg from the repositories, because the direct option above gave me an error. To have it appear in the list of available packages in octave, you have to specify the presence of such globally installed pkgs:

octave:4> pkg global_list /usr/share/octave/octave_packages 
octave:5> pkg list
Package Name         | Version | Installation directory
---------------------+---------+-----------------------
fuzzy-logic-toolkit  |   0.4.5 | /media/tasos/Gandalf/opt/octave-4.2.1/lib/fuzzy-logic-toolkit-0.4.5
              image *|   2.6.1 | /media/tasos/Gandalf/opt/octave-4.2.1/lib/image-2.6.1
                 io *|   2.4.7 | /media/tasos/Gandalf/opt/octave-4.2.1/lib/io-2.4.7
             odepkg  |   0.8.5 | /usr/share/octave/packages/odepkg-0.8.5
         statistics *|   1.3.0 | /media/tasos/Gandalf/opt/octave-4.2.1/lib/statistics-1.3.0

However, in general, it's probably more useful to install such packages locally, as the package versions in the repositories are often out-of-date (and having to do pkg global_list every time is a hassle); I would only install global packages from the linux terminal if a local installation within octave doesn't work for whatever reason (e.g. giving compilation errors).

See the documentation of the pkg command for more details, by doing help pkg in the octave terminal.

like image 147
Tasos Papastylianou Avatar answered Oct 11 '22 11:10

Tasos Papastylianou