Tuesday, April 11, 2017

Creating and customizing 3D graph in MATLAB.

Unlike 2D figure, 3 variables are involved in a 3D figure. Below is an example of 3D mesh graph. For certain value of X and Y, we plot the value of Z.
Example :
        Z = (X  /  (c*Y))
3D figure can be bar, mess, surf etc...

Let's begin drawing the graph for the equation
        Z = (X  /  (c*Y))

Step-1: Prepare the data

X = [0.1000    0.1889    0.2778    0.3667    0.4556    0.5444    0.6333    0.7222    0.8111    0.9000]
Y = [-0.1000   -0.1889   -0.2778   -0.3667   -0.4556   -0.5444   -0.6333   -0.7222   -0.8111   -0.9000]
c = 0.05

Here I have used the following Matlab code to generate the data for X and Y.
X = linspace(0.1,0.9,10)
Y = linspace(-0.1,-0.9,10)

for X, 0.1 is the initial value, 0.9 is the final value, and 10 is the number of values to be generated between initial and final value. Similarly for Y also. 


Now In order to generate the data for 3D surf convert X and Y data to a meshgrid.
Step-2: 
           [mx, my] = meshgrid(X, Y);

Step-3: Generate data for Z-axis
           Z = mx ./ (c.*my);

Step-4: Get ready to plot the data onto a 3D figure.

Enter the following code


figure1 = figure();

% Create axes
axes1 = axes('Parent',figure1);
hold(axes1,'on');
% Create xlabel
xlabel('X-axis Label');

% Create ylabel
ylabel('Y-axis Label');

% Create zlabel
zlabel('Z-axis Label');

view(axes1,[152.1 22]);


% Create surf
surf(ax,ay,Z,'Parent',axes1);

grid(axes1,'on');

% Set the remaining axes properties
set(axes1,'FontName','Times New Roman','FontSize',14,'FontWeight','bold',...
    'XTick',[0.1 0.3 0.5 0.7 0.9],'XTickLabel',...
    {'0.1','0.3','0.5','0.7','0.9'});

Final Step:
The entire Matlab file will look like this

X=linspace(0.1,0.9,10);
Y=linspace(-0.1,-0.9,10);
c=0.05;

[ax, ay] = meshgrid(X,Y);
Z = ax ./(c.*ay);

figure1 = figure();

% Create axes
axes1 = axes('Parent',figure1);
hold(axes1,'on');
% Create xlabel
xlabel('X-axis Label');

% Create ylabel
ylabel('Y-axis Label');

% Create zlabel
zlabel('Z-axis Label');

view(axes1,[152.1 22]);


% Create surf
surf(ax,ay,Z,'Parent',axes1);

grid(axes1,'on');

% Set the remaining axes properties
set(axes1,'FontName','Times New Roman','FontSize',14,'FontWeight','bold',...
    'XTick',[0.1 0.3 0.5 0.7 0.9],'XTickLabel',...
    {'0.1','0.3','0.5','0.7','0.9'});


Bonus tips: Customizing the axis label with text() and annotation().

Disable xlabel(), ylabel(), and zlabel() if you are going for text() or annotation() command.

text() example:
% After running this .m file edit the position of each text box
   ty=text(0.5,0.5,'Y-axis label','Rotation',-28,'FontSize',20,...
    'FontWeight','bold','FontName','Times New Roman');

annotation() example:

  annotation(figure1,'textbox',...
     [0.528242677824266 0.789163935354498 0.0753138055985942 0.0475409826782883],...
     'String',{'? = 0.5'},...
     'FontWeight','bold',...
     'FontSize',12,...
     'FontName','Times New Roman',...
     'EdgeColor',[0.24705882370472 0.24705882370472 0.24705882370472],...
     'BackgroundColor',[1 1 1]);

Thats all for now. 
Please comment if more customization function you need.


Thank you


Thursday, November 24, 2016

Installing packages (Python, R and Scala) with Anaconda.

Anaconda makes the package management of Python, R and Scala very easy. For this you need to have Anaconda-navigator package installed in your computer.



1. Open Command prompt
2. Enter conda install anaconda-navigator
3. Press Enter key to proceed.

Now open anaconda navigator application. Below is the Home screen of Anaconda navigator.
1. Home Screen


Click on Environments, as shown below
2. Environment screen


Change the Installed option to All option Select
3. Change "Installed" to "All" option

4. Differentiate "Installed", "Not installed" and "Upgradable " packages.

Now Type the required package in the Search box.
Lets install "pandasql" package . So type pandasql in the search box. Now you can see the search result.

5. Search required package


Now right click on the checkbox in the respective search result. From the options , select "Mark for installation"

6. Installation option


Click on "Apply" button.
Now click on "Ok" button.
7. Final steps.


Its finish. Repeat the same process for installing other packages.




Installing Anaconda in Windows OS.


Step 1: Download
First step is to download the latest version of Anaconda for Windows OS.

For Windows 64bit (Python 3.5): https://repo.continuum.io/archive/Anaconda3-4.2.0-Windows-x86_64.exe
For Windows 32bit (Python 3.5):  https://repo.continuum.io/archive/Anaconda3-4.2.0-Windows-x86.exe

For Windows 64bit (Python 2.7): https://repo.continuum.io/archive/Anaconda2-4.2.0-Windows-x86_64.exe
For Windows 32bit (Python 2.7):  https://repo.continuum.io/archive/Anaconda2-4.2.0-Windows-x86.exe

You can also download from official link https://www.continuum.io/downloads.

Step 2 : Install
Install Anaconda 3.5 (Python 3.5)
  1. Double click on the downloaded file.
  2. Follow the wizard.
  3. Select "Just me..." option, and click on "Next" button.
  4. In the "Advanced Installation Options", please make sure that "Add Anaconda to my PATH...." and "Register Anaconda....."  options are checked.
  5. now just follow the wizard and finish the installation process.

Step 3: Verify the installation
Open command prompt
Enter following command
 conda --version

Monday, October 31, 2016

Installing and running the docker daemon remotely.

Step-1: Installing the Docker
         sudo apt-get install docker.io
After installing, docker will start running automatically.
Step -2: Stoping the docker
         sudo service docker stop

Step-3: configuring the docker
  
sudo docker -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock -d &
This will make the docker daemon to listen through unix socket and the TCP port


Now access the docker daemon 
example-1
  docker -H=tcp://120.126.17.39:2375 run ubuntu


example-2
   docker run ubuntu

example-3
  docker -H=tcp://120.126.17.39:2375 ps -a


example-4
    docker ps -a


For uninstalling use following command
  sudo apt-get purge --auto-remove docker.io
 



When docker-engine is install, I found the command is slightly different from the previous one.
To install docker-engine:  [src]
        sudo apt-get install docker-engine
Stop the docker:
        sudo service docker stop
Following command will enable the docker to listen using both Linux socket and tcp:
          sudo dockerd -H unix:///var/run/docker.sock H tcp://0.0.0.0:2375
Now to access docker daemon:
          sudo docker -H tcp://0.0.0.0:2375 
                 or 
          sudo docker -H tcp://120.126.16.34:2375

tcp://120.126.16.34:2375 is the IP of the daemon host. The IP of daemon host can be different based on your configuration.

Thursday, October 27, 2016

Which port is opened in my Linux system ?

netstat command can be used to know all ports opened currently.

command 

netstat  <option>

option:
-a                              short form of '--all'
-t or --tcp                  for tcp connection
-u or --udp                for udp connection
-n                              for numeric presentation

Example

netstat -atn                     for all tcp connection
netstat -aun                    for all udp connection

netstat -ltn                     for all ACTIVE tcp connections
netstat -lun                     for all ACTIVE udp connections

Friday, October 21, 2016

Uninstalling Docker-engine from Ubuntu 14.04

Completely Uninstalling Docker-engine including Configuration data and other dependencies

        sudo apt-get purge --auto-remove docker-engine

Uninstalling Docker and its dependencies

        sudo apt-get remove --auto-remove docker-engine

Uninstalling Docker and its configuration data

        sudo apt-get purge docker-engine

Uninstalling only Docker

        sudo apt-get remove docker-engine

Thursday, October 20, 2016

Accessing remote printer [Fuji Xerox DocuPrint m215b]

In this post we will see, how to access a shared remote printer. Below picture describes the concern environment.


Let's say you as the user want to access the printer attached to another computer which is connected to internet. Its assume that the printer is already shared. So this post is all about configuring the user's computer to access the remote printer.

Environment :

OS: Windows 8 (The steps may vary slightly in other versions of Windows)
Printer Driver: In this demonstration Fuji Xerox DocuPrint m215b is used.
                           Driver for Windows 64bit  OS
                            (Compatible OS: Windows 7, Windows 10, Windows Server 2003, Windows Server 2003 64bit, Windows Vista, Windows Vista 64bit, Windows Server 2008, Windows Server 2008 64bit, Windows Server 2008 R2, Windows 7 64bit, Windows 8, Windows 8 64bit, Windows 8.1, Windows 8.1 64bit, Windows Server 2012, Windows Server 2012 R2, Windows 10 64bit )
                             (Click here to download the driver from official website)



 Driver Installation steps



Step1:  Download the Printer driver
Step 2: Now extract the content of the downloaded driver. Open the newly created Folder.

Step 3: Right click on the application and click on "Run As Administrator"

Step 4: Click on Unzip

Step 5: Now you will see another folder. Now close the dialog box and open the newly created folder.

Step 6 :  Now run the "install" application by double clicking on it.

Step 7:  Select "Personal installation" radio button and click on next button.

Step 8:  Click on "next" button after accepting the license agreement.

Step 9: Now wait for few mins

Step 10 : Click on "Finish" button to finish the installation process.




Adding Remote printer



Step 1: Open the control panel, and click on "Devices and Printers"

Step 2:  Click on "Add a printer"

Step 3:  Wait for auto search. Or you can click on "The printer that I want isn't listed"

Step 4:  Give the printer name (including computer name) and click on "Next" button.

Step 5:  You must see the printer name. Click on "Next" button.

Step 6: Click on "Print a test page" to check the accessibility of the printer. click "Finish" button to finish the configuration process.


That's all for now...Please comment if you encounter any problem.

-Thank you





Thursday, October 6, 2016

Installing OpenCV and Python in Windows


1. Download and install Python 2.7.x in windows
             windows install : http://python.org/ftp/python/2.7.5/python-2.7.5.msi
2.  The default installation directory C:\Python27


3. Download and install python package manager pip if NOT installed
                  A. Download get-pip.py script from  https://bootstrap.pypa.io/get-pip.py
                  B. Open command prompt
                  C. Enter following command to run the downloaded script
                                    python <path to get-pip.py file>

4.  Go to http://www.lfd.uci.edu/~gohlke/pythonlibs/ to download and install python packages

5.  Now, Download Numpy python package (choose the .whl file based on your requirement)
                  A. Open command prompt
                  B. Go to the local directory where numpy-1.11.2+mkl*.whl file is present
                  C. Enter following command to Install Numpy
                                    pip install numpy-1.11.2*.whl
6. You can repeat Step-5 to install other required packages


7. Download and install OpenCV
                  A. Folllow the link to download OpenCV-3.1.0
                  B. Open the .exe file to install (in C drive)
                  C. Goto C:\opencv\build\python
                  D. Copy cv2.d to C:\Python27\Lib\site-packages

Please comment if you encounter any error....

-Thank you 

Tuesday, September 13, 2016

How to install TexStudio with Miktex ?

In order to work with Latex,  texStudio is one of the best solutions as TeX editor.
See the comparison of TexStudio with other other text editor.

Download the following software.

  1. Latex editor: TeXstudio 
    1. Select according to your OS environment.
  2. Repository: miktex repository 
    •  
      select the version according your OS environment
    •  Save the installer file, such as "setup-2.9.6050.exe"
    • If you have very good internet connection, better you download 'net install' which allow you to download the complete MikTeX repository.
So, now you must have the following software packages

Downloading and Installing MikTeX repository

1.  Open the miktex installer file. Here it is "Setup-2.9.6050.exe"
2.  Click on 'Next' button....

3.  Select 'Download MiKTeX' option to keep the repository for future purpose. <4.JPG>
4.  Select "Complete MiKTeX" option to install all packages.

5.  Now the choose the download source and click on 'Next' button.

6.  Give the location, where you want to keep the downloaded repository.

7.  Now the final step to download the repository. Click on "Start" button.

8. Now you need to wait until the download finish.
9. Once the download is finished, click on "Next" button.

10. Click on "Close" button.

      Here we finish downloading the MiKTeX repository. Now we perform the installation process.
11. Open the same miktex installer file again and follow step 2. Here it is "Setup-2.9.6050.exe"
12. Now Select "Install MiKTeX" option and click on "Next" button.

13. Now select "Complete MiKTeX" option and click on "Next" button.
14. Select the user based on your requirement and click on "Next" option.

15. Now you need to specify the path of already downloaded MikTeX repository. Click on "Next" button.

16. Now click on "Next" button, leaving the default installation directory.
17. Leave the default setting, and press "Next" button.
18. Click on "Start" button after reviewing the settings.
19. After the installation process finish, click on "Next" button and then click on "Close" button.

Installing TeXstudio   
Now install TeXstudio editor. Installing TeXstudio is quite easy. Just follow the installation wizard and leave all the setting as default. Below are some screenshot given for reference.
1
2

3

4

5

6

7










Thursday, September 8, 2016

Golang and Shell Script : Execute sh file from Go file and vice-versa.

We will see here today, executing a Go file from Shell script file and vice-versa.

Don't know, how to create and run a shell script file ?
Shell script file name : hello_sh.sh
Content of hello_sh.sh :

echo "Hello, I am inside 'hello_sh.sh' file."
echo "Now, I am going to call 'hello_go.go' file. The output: "
go run hello_go.go


Hello world ! program in Golang.
Go file name : hello_go.go
Content of hello_go.go :


package main
import (
        "bytes"
        "fmt"
        "log"
        "os/exec"
        "strings"
)
func main() {
        fmt.Printf("Hello, I am from 'hello_go.go' file.");
        fmt.Printf("\nNow, I am going to execute 'hello_sh.sh' file\n");
        cmd := exec.Command("bash", "hello_sh.sh");
        cmd.Stdin = strings.NewReader("");
        var out bytes.Buffer;
        cmd.Stdout = &out;
        err := cmd.Run();
        if err != nil {
                log.Fatal(err);
        }
        fmt.Printf("Output \n",out.String());
}


*For beginner change the file name "hello_sh.sh" and  "hello_go.go" according to your requirement.
*For advanced programmer, try this recursion and you can comment your output below.


-Thank you