Mar 13, 2015

GNU Octave

GNU octave is a high level language for numerical computation. It is pretty much similar to Matlab, but it is free. From the version 3.8 onward, the octave supports GUI as well.

To install Octave in Linux Environment, do following in terminal:

$ sudo add-apt-repository ppa:octave/stable
$ sudo apt-get update
$ sudo apt install octave

or 

$ sudo apt-get install octave

(I used the 2nd one, so not sure about the first one, but it should work)

After installing octave, you can find the octave in search bar or under menu-> Science & Engineering-> GNU Octave or, from terminal as:

$ octave

Following octave command prompt will appear:


We can start Octave in GUI mode by forcing the GUI mode by following command:
At terminal:

$ octave --force-gui

Then, GUI appears as follow:



The programming construct are pretty much similar. Code are likely to be compatible with matlab. It has plot functions and array pretty similar with matlab. 

Here is a sample of octave script - test.m

#! bin/octave -qf
clear;
clc;

N=[2,4,5,6,7,4,3,6]
lengthN = length(N);
sum=0.0;
for i = N
  sum += i;
  endfor
meanN=sum/lengthN;
printf("The mean  = %f \n", meanN);
printf("The median  = %f \n", median(N));
printf("The variance = %f \n", var(N));
printf("The standard deviation = %f \n", std(N));

bar(N)
axis([0,10,0,10]);
title("The traffic load");
xlabel("Time Slot");
ylabel("Number of customer")
grid on;

Enjoy!



No comments:

Post a Comment