B.1  Matlab and Octave

For using the companion code, add the respective directories to the Matlab/Octave PATH with commands such as addpath(genpath(’C:/mydir/Code/’),’-end’) and savepath.

In spite of many similarities, Matlab and Octave are of course two distinct softwares. In fact, compatibility with Matlab is not the top priority in Octave’s development. Hence, even if a function has the same name and syntax, the algorithms are typically implemented differently and may lead to discrepant results. Besides, Mathworks is strategically substituting functions by classes in new versions, such that functions such as butter (for designing a filter) are invoked after an object is created. This has been making Matlab and Octave increasingly different.

As another example of distinct behavior, fir1 in Matlab normalizes the filter using:

1if First_Band 
2    b = b / sum(b);  % unity gain at DC 
3else 
4    ...

while fir1 in Octave uses:

1  ## normalize filter magnitude 
2  if scale == 1 
3    ## find the middle of the first band edge 
4    if m(1) == 1, w_o = (f(2)-f(1))/2; 
5    else w_o = f(3) + (f(4)-f(3))/2; 
6    endif 
7    ## compute |h(w_o)|^-1 
8    renorm = 1/abs(polyval(b, exp(-1i*pi*w_o))); 
9    ## normalize the filter 
10    b = renorm*b; 
11  endif

Therefore, the command B=fir1(10,0.4) in Matlab generates a filter that has a gain of 1 at DC, while this command in Octave generates a filter with gain of 0.7557 dB at DC.

The bilinear function is a representative example of different syntaxes, which is a major problem when dealing simultaneously with Matlab and Octave. While Matlab uses the sampling frequency Fs, Octave uses the sampling period Ts = 1Fs. Hence, for obtaining approximately the same results, the call [NUMd,DENd] = bilinear(NUM,DEN,Fs) in Matlab must be mapped to [NUMd,DENd] = bilinear(NUM,DEN,1/Fs) in Octave. Another example of discrepancy is the third argument of pwelch.m). Octave assumes it is a percentage while Matlab assumes it is the number of samples. The Web has good sites comparing the two softwares, such as [ urlomoc].

B.1.1  Octave Installation

The primary source for Octave is [ urlooct]. But, for better organization, most of Octave’s packages (called toolboxes in Matlab’s jargon) are kept separated, at Octave Forge: [ urloofo]. Therefore, after installing Octave itself, it may be necessary to download and install its packages (toolboxes).

After installing Octave, from its prompt, the command ver can be used to verify not only the Octave version but also its toolboxes. For example, the toolbox signal is required to execute several of the companion scripts. When using Linux, it is possible to use a command such as [ urloins]:

1sudo apt-get install $( apt-cache search octave-forge | awk '{printf $1; printf " "}' )

to install the packages.

An alternative to this two-steps installation procedure is to obtain a complete “distribution” of Octave, with all (or most) packages of interest already incorporated. For example, installing Octave on Windows can be simplified by following the guidelines at [ urlowin], which indicate how to install the Octave executable from a single file and then most of its packages from a second compressed file.

It is suggested to add the folder with the companion functions in your Octave PATH using addpath. For example, to add the folder

C:\Code\MatlabOctaveFunctions

in a Windows machine, avoid the backslash using

addpath("C:/Code/MatlabOctaveFunctions","-end")

or

addpath(["C:" filesep "Code" filesep "MatlabOctaveFunctions"],"-end")

and use savepath to save the modifications.

Make sure the command sound (or soundsc) is working. You may need to install a sound player and inform Octave of its PATH using an Octave’s global environment variable called sound_play_utility. A good strategy is to setup this variable at the .octaverc file with something like global sound_play_utility = "c:/Program Files/VideoLan/VLC/vlc", but changing the PATH to your installed audio player [ url1rec].

Then keep your Octave installation up to date. For installing a package, for example, from the Octave prompt it is possible to run pkg install -forge signal to install the signal package.

Another point worth mentioning is that some packages, such as the Fixed Point, are not part of the ones supported by Octave Forge and need to be installed individually (taking in account their compatibility with the installed version of Octave).