Compress files in MATLAB without other file compression software – Method 3, tar & untar

In the previous post and the post before that, I mentioned two methods for compressing and decompressing files directly in MATLAB using standard ZIP and GNU ZIP methods. In this folder, I demonstrate that we can make tar files using MATLAB.

The following function creates a tar file from the list of files and folders specified in the second argument files.

tar(tarfilename,files)
The tarfilename can have an extensoin. If it doesn’t the default extension is .tar. The other extensions can be .tgz or .gz.
Example:
tar('files.tgz','Downloads');   % saves the result in the Download folder
tar('files.tgz','.');    % saves the result in the current folder

 

Compressing and decompressing:

tar('myfiles.tar.gz','*.mdl');
untar('myfiles','Documents');

Note:

tar cannot compress folders larger than 2 GB.

Posted in Linux, MATLAB, programming, Software, Ubuntu | Tagged , , , , , , , , , , , , , , , , | Leave a comment

Compress files in MATLAB without other file compression software – Method 2, GNU ZIP-UNZIP

In previous post, I showed how you can make zip files in MATLAB and also how to unzip them. The previous function zip used the standard ZIP compression.

In this post, we take a look at GNU ZIP and GNU UNZIP methods for compressing and decompressing files in MATLAB without requiring any external software.

The two functions we use are gzip and gunzip( In this case, the compressed file extension is gz). The usage is exactly similar to zip and unzip from the  previous post.

gzip(files,outputdir)

unzip(zipfilename,outputdir)

 

Example:

gzip({'*.m','*.mdl'},'myfolder');

gunzip('*.gz');

Check out my previous post for compressing & decompressing using zip and unzip.

Check out my next post for compressing & decompressing using tar and untar.

Posted in Linux, MATLAB, programming, Software, Ubuntu | Tagged , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

Compress files in MATLAB without other file compression software – Method 1, ZIP-UNZIP

You can easily zip a file (or a set of files) in MATLAB without requiring any external compression software being installed on your machine. This is useful to be able to compress files while still in MATLAB.

In this post, I show some examples.

ZIP

1- ZIP a file with the following command:

zip(zipfilename,files)

Example for a single file:

zip('myfile','model_1.mdl');

Example with multiple files:

zip('myfile', {'model_1.mdl','main.m','objective.m'});

Example for all files with the same extension:

 zip('myfile',{'*.m','*.mdl'}); 

UNZIP

Use Unzip to decompress the Zip files:

unzip(zipfilename,outputdir)

Example:

unzip('myfile','matlab_folder');

Check out my next post for compressing & decompressing using gzip and gunzip.

Check out my next post for compressing & decompressing using tar and untar.

Posted in Linux, MATLAB, programming, Software, Ubuntu | Tagged , , , , , , , , , , , , , , , , , , , , , | Leave a comment

How to install both Python 2.x and 3.x on you machine?

First install Python 2.x using the windows installer from here.
Make sure, you tick the box that says add python.exe to your path.

Let’s say you install it at: c:\python27

The installer will add python to the system’s Path and will edit your environment variables to include C:\Python27\;C:\Python27\Scripts\;

Now you should install python 3.x using the windows installer.
This time make sure the add python.exe to your path remains unchecked.

Let’s say you install it at c:\Python35
Now go into this folder and rename the following files:

  • python.exe –> python3.exe
  • pythonw.exe –> pythonw3.exe

The next step is adding the following string to your path manually.
C:\Python35\;C:\Python35\Scripts\;

Now, in a command line, you can type python and the python 2.x interpreter will start,

or enter python3 and python 3.x interpreter will start. (you might need to restart before the path is reloaded to the memory)

Posted in Linux, programming, Python, Software, Ubuntu | Tagged , , , , , , , , , , , , , , , , , , , | Leave a comment

SO(3) vs. so(3)

SO(3) – Definition

The set of all 3\times3 rotation matrices, \mathbb{R}^{3 \times 3}, which satisfy the following two properties is denoted SO(3) ,

  1. det(R)=+1
  2. RR^T = R^TR = I

The notation SO refers to Special Orthogonal.

More generally, we can define the space of rotation matrices in \mathbb{R}^{n\times n} by

SO(n)=\{ R \in \mathbb{R}^{n \times n} : RR^T=I, det(R)=+1\}

so(3) – Definition

The vector space of all 3 \times 3 skew matrices is denoted so(3) and more generally the space of n \times n skew-symmetric matrices is

so(n)=\{ S \in \mathbb{R}^{n \times n} : S^T=-S\}

Relationship between SO(3)  and so(3)

Every rotation matrix can be represented as the matrix exponential of some skew-symmetric matrix; that is the map exp: so(3) \rightarrow SO(3) is surjective.

In other words, given R \in SO(3), there exists \omega \in \mathbb{R}^{n \times n}, \| \omega \| = 1, and \theta \in \mathbb{R} such that R=\exp(\hat{\omega}\theta).

Example

\exp(\hat{x}\theta)  = \left[ \begin{array}{ccc} 1 & 0 & 0 \\ 0 & \cos(\theta) & -\sin(\theta) \\ 0 & \sin(\theta) & \cos(\theta) \end{array} \right]

Posted in Machine Learning, Robotics | Tagged , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

Installing necessary modules on python – (whl version)

There are several very nice python packages that I use everyday. They include: numpy, scipy, matplotlib, …I used to install these packages on windows using pre-built binary installers.

Recently, I have noticed that those installers are being disappeared and in order to keep them updated you need either to install very large packages such as Anaconda or build the packages on your machine from source.

Then I found Unofficial Windows Binaries for Python Extension Packages. Here you can find almost all existing packages for python as whl files.

This page provides 32- and 64-bit Windows binaries of many scientific open-source extension packages for the official CPython distribution of the Python programming language. The files are unofficial (meaning: informal, unrecognized, personal, unsupported, no warranty, no liability, provided “as is”) and made available for testing and evaluation purposes. Most binaries are built from source code found on PyPI or in the projects public revision control systems. Source code changes, if any, have been submitted to the project maintainers or are included in the packages. You should use pip version 8 or newer to install the downloaded .whl files.

Since many binaries depend on numpy+mkl, install it before other packages that depend on it. As you can notice, the numpy has changed to numpy+mkl.
Numpy+MKL
is linked to the Intel® Math Kernel Library and includes required DLLs in the numpy.core directory.

Step 1. Download the whl files you need (for instance on python2.7 32bit):

numpy-1.11.3+mkl-cp27-cp27m-win32.whl
scipy-0.19.0-cp27-cp27m-win32.whl
matplotlib-1.5.3-cp27-cp27m-win32.whl

Step 2. Run a command window as administrator in windows

Window+R
Type: cmd
R-click
select Run as Administrator

Step 3. Install the whl files one by one:

pip install numpy-1.11.3+mkl-cp27-cp27m-win32.whl
pip install scipy-0.19.0-cp27-cp27m-win32.whl
pip install matplotlib-1.5.3-cp27-cp27m-win32.whl

Step 4. Test in a command-line to see everything is OK:

c:\python
>>> import numpy as np
>>> import scipy as sp
>>> import matplotlib.pyplot as plt

 

 

Posted in programming, Python, Software | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment