loading...

Use of GNU Octave over MATLAB and a general comparison between them


Introduction: 
GNU Octave is a high-level language, primarily intended for numerical computations. It provides a convenient command line interface for solving linear and non-linear problems numerically, and for performing other numerical experiments using a language that is mostly compatible with MATLAB.

Abstract: 
GNU Octave is basically an open-source software and can be easily downloaded and freely used for solving almost all the critical problems as much as is possible in the case of Mathworks (Trade Mark.) MATLAB. Although you have to pay a high fee for access to the large library and functions provided by MATLAB, whereas in case of GNU Octave it is not so. GNU Octave is a free of cost and open-source software (comes with the perks of being an open-source software), easily customizable software. Specially for students who are spared with just one month of free subscription for the expensive MATLAB software, GNU Octave comes as a boon.

How to download: Below I will be providing with the links to download both GNU Octave and MATLAB and explain the steps to do so:

       To install GNU Octave follow the steps given below:

        
Download (gnu.org)
Download the Octave installer file from the link above.
Save the downloaded file to your computer.
Double-click on the downloaded Octave installer file.
Now, a smart screen might appear and ask for a confirmation.
Click “Yes” to confirm.
Finally, follow the installation instructions until you get a confirmation notification of a successful installation process.

      To install MATLAB follow the steps as provided below:



    1. Double click on the MATLAB icon (the binary file which we downloaded earlier). After clicking the icon, a pop-up will ask for the installer to run, click on the Run. A MathWorks Installer window will pop-up on the screen.
    2. A license Selection window will appear, a preselected license id will be highlighted with a blue background. Here you have to select your license id; this is the id which we have saved during STEP 9 of downloading of the installer (we urged to note down that id during that time) and again click on Next. 
    3. Next is Product Selection window, the first product is MATLAB 9.6, this is mandatory to select because it is the MATLAB environment, and from other products, you can choose as many of your choices and click on Next. 
    4. After downloading of all products and completion of the installation, a window appears that says to Activate the MATLAB, no need to do anything, click on the Next button. 
    5. A MATLAB shortcut will be created on the desktop as per our choice during the installation process. Now we can work with MATLAB by clicking on the icon placed there on the desktop.

Features of GNU Octave:

1. Command and variable name completion

Typing a TAB character on the command line causes Octave to attempt to complete variable, function, and file names (similar to Bash's tab completion). Octave uses the text before the cursor as the initial portion of the name to complete.

2. Command history

When running interactively, Octave saves the commands typed in an internal buffer so that they can be recalled and edited.

3. Data structures

Octave includes a limited amount of support for organizing data in structures. In this example, we see a structure "x" with elements "a", "b", and "c", (an integer, an array, and a string, respectively):
octave:1> x.a = 1; x.b = [1, 2; 3, 4]; x.c = "string";
octave:2> x.a
ans =  1
octave:3> x.b
ans =

   1   2
   3   4

octave:4> x.c
ans = string
octave:5> x
x =
{
  a =  1
  b =

     1   2
     3   4

  c = string
}

4.Short-circuit boolean operators
Octave's '&&' and '||' logical operators are evaluated in a short-circuit fashion (like the corresponding operators in the C language), in contrast to the element-by-element operators '&' and '|'.
5.Increment and decrement operators
Octave includes the C-like increment and decrement operators '++' and '--' in both their prefix and
postfix forms. Octave also does augmented assignment, e.g. 'x += 5'.

6.Unwind-protect
Octave supports a limited form of exception handling modelled after the 'unwind_protect'of Lisp. The general form of an unwind protect block looks like this:
unwind_protect
   body
unwind_protect_cleanup
   cleanup
end_unwind_protect
7.Variable-length argument lists
Octave has a mechanism for handling functions that take an unspecified number of
arguments without explicit upper limit. To specify a list of zero or more arguments,
use the special argument varargin as the last (or only) argument in the list.

function s = plus (varargin)
   if (nargin==0)
      s = 0;
   else
      s = varargin{1} + plus (varargin{2:nargin});
   end
end
8.Variable-length return lists

A function can be set up to return any number of values by using the special return
value varargout. For example:
function varargout = multiassign (data)
   for k=1:nargout
      varargout{k} = data(:,k);
   end
end
9.C++ integration
It is also possible to execute Octave code directly in a C++ program. For example,
here is a code snippet for calling rand([10,1]):

#include <octave/oct.h> ...
ColumnVector NumRands(2);
NumRands(0) = 10;
NumRands(1) = 1;
octave_value_list f_arg, f_ret;
f_arg(0) = octave_value(NumRands);

f_ret = feval("rand", f_arg, 1);

Matrix unis(f_ret(0).matrix_value());

C and C++ code can be integrated into GNU Octave by creating oct files, or using the MATLAB compatible MEX files.

Conclusion:
Majority of the features similar to MATLAB are debuted by this open source, free software
and thus GNU Octave can be fully utilised by an Engineer and other interested fellow doing
mathematical computations in higher levels.

Thus it is a very useful, and proven alternative for MATLAB alongside SCILAB and has been
providing a truly remarkable service over the years and years to come.