Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

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!



Feb 27, 2015

Powerful awk

Awk is really a powerful script language. We can perform a large tasks within a few line of codes. Just for example:

Consider we have a sample spreadsheet with the information as below:

test_awk.csv

Consider we want to find how many different records are in the 3rd column, we can use the following command in the terminal or bash:

           awk '{print $3}' test_awk.csv | sort -n | uniq -c

Output:

       1 x121REB000
     12 x121REB227
      6 x131REB198
      4 x131REB205
     20 x131REB221
      4 x131REB254
      3 x131REB294
      1 x131REB317
      5 x131REB392


And, consider we want to find number of TRUE and number of FALSE, for each uniuqe record in the column 3, we can run following commands:

          awk '{print $3, /TRUE/, /FALSE/}' test_awk.csv | sort -n | uniq -c

Output:

 Count   Code         T  F 
      1  x121REB000 0 1
     11 x121REB227 0 1
      1  x121REB227 1 0
      1  x131REB198 0 1
      4  x131REB198 1 0
      1  x131REB198 1 1
      3  x131REB205 0 1
      1  x131REB205 1 0
     17 x131REB221 0 1
      3  x131REB221 1 0
      2  x131REB254 0 1
      1  x131REB254 1 0
      1  x131REB254 1 1
      2  x131REB294 0 1
      1  x131REB294 1 0
      1  x131REB317 0 1
      4  x131REB392 0 1
      1  x131REB392 1 0

Lastly, for each record in column no. 3,  to find the unique record in field number 2, we can use the command:

          awk '{print $3, $2}' test_awk.csv | sort -n | uniq

Output:

Code-3 Code-2
x121REB000 5921
x121REB227 5724
x121REB227 9087
x131REB198 1443
x131REB198 1841
x131REB198 2339
x131REB198 5261
x131REB198 7284
x131REB198 9758
x131REB205 1446
x131REB205 1958
x131REB205 2285
x131REB205 5999
x131REB221 3866
x131REB221 6171
x131REB221 9616
x131REB221 9898
x131REB254 4732
x131REB254 6078
x131REB254 7679
x131REB254 9112
x131REB294 1025
x131REB294 3369
x131REB294 6006
x131REB317 6452
x131REB392 4045
x131REB392 4898



Feb 9, 2015

Install Oracle Java for Netbeans

I was trying to install Netbeans in Ubuntu 14.0.4. But default Java for this version of Linux is OpenJDK7, which was not compatible with the netbeans. So I had to install the Oracle Jave so that the installation of Netbeans can be continued.

Here is the process to install Oracle Java:

Linux Terminal:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
 
After that, Netbeans will install in Ubuntu.
 
Process to install Netbeans in Ubuntu can be seen in this Site of Netbeans.