Saturday, January 31, 2009

Vectors and Matrices - 1

The Scilab is like Matlab (Matrix Lab), I don't like Matlab but it's other thing.

The Scilab was created for matrix manipulation, so it can operate matrices (and similars) naturally.

This is the first post about vectors and matrices.

Let's do something.

Get a vector
x = [1 2 3 4]' (x is a column vector)
and a matrix
A = [1 2 3 4;
1 2 3 4;
1 2 3 4;
1 2 3 4].

If y = A x (matrix multiplication), then y = [x[1]A[1,1]+x[2]A[2,1]+x[3]A[3,1]+x[4]A[4,1] x[1]A[1,2]+x[2]A[2,2]+x[3]A[3,2]+x[4]A[4,2] x[1]A[1,3]+x[2]A[2,3]+x[3]A[3,3]+x[4]A[4,3] x[1]A[1,4]+x[2]A[2,4]+x[3]A[3,4]+x[4]A[4,4]] = [1²+2²+3²+4² 1²+2²+3²+4² 1²+2²+3²+4² 1²+2²+3²+4²] = [30 30 30 30].

For who studies linear algebra, the equation y = A x is a generic linear system of 1st order.

Using Scilab, we can do the commands.

-->x = [1 2 3 4]'; // the apostrophe { ' } indicates the transposition, so x is a column vector because [1 2 3 4] is a line vector and x is [1 2 3 4] transpose.

-->A = [1 2 3 4;
-->1 2 3 4;
-->1 2 3 4;
-->1 2 3 4];

-->y = A*x
y =

30.
30.
30.
30.

Look that y is a column vector like x (with 4 lines), it's correct because A is a square matrix (with 4 lines and 4 columns) and x is a column vector (with 4 lines).

Using the rule dim(y) = dim(Ax) = [number of lines of A, (number of columns of A, number of lines of x), number of columns of x] = [number of lines of A, number of columns of x] (parenthesis out).

I'll do more posts about vectors and matrices. Wait and see.

Monday, January 26, 2009

Starting Scilab

The first step for use Scilab is install it.

GNU/Linux users can use the apt-get (apt-get install scilab scilab-bin scilab-doc), Synaptic or compile the codes (from here).

Window$ users can download the installer here.

After install, let's use the Scilab.

This is the initial screen.

Scilab is a interpreted programming language like Python.

The showed screen is the Scilab's prompt, let's do something now.

Write the commands:

--> x = 0;

--> y = 1;

--> z = 2;

Each line declares a variable (x, y and z) and starts it value with 0, 1 and 2, respectively, in float format (in Scilab, all numbers are float, by default).

Let's do operations with the variables now.
-->res1 = x + y - z
res1 =

- 1.

-->res2 = (x + y)*z
res2 =

2.

-->res3 = (-x + y)/z
res3 =

0.5


With the 4 arithmetic operations, we can do any numeric simulation.

In next posts, I'll show what the Scilab can do.

Thursday, January 15, 2009

Presentation

This is my 1st dedicated blog and I created it just for teach something about Scilab.

The Scilab is a very powerful software for numeric computation.

I'll share codes and programming technicals, but I'd like receive comments and interactions with the blog (votes in the polls, for example).

Now, let's start the presentation.

I'm a engineer of teleinformatics and I'm doing mastering in engineering of teleinformatics. My favorite study areas are digital images and signals processing, computational vision, patterns recogntion, computational intelligence and intelligent automation.

I work with free software since 2004 (when I joined the University), I'm using just GNU/Linux for my own activities and works.

I use Scilab since 2005 and I love it, because everyone uses the Matlab and I don't like proprietary software, I think free software stimulates the desire for knowledge. I like a lot learn new things and free software does it.