# Very short Matlab/Octave tutorial

### From GHER

## Start Octave/Cygwin

- Click on Cygwin icon
- type "startx" in newly opened window with the black and green icon
- may open new terminal by type "xterm &" in window with the X icon on the left
- type "octave" in one of the windows with the X icon on the left. This is your octave session. All octave commands have to typed there

## Basic commands of octave

Normally Matlab/Octave shows the results of each operation on the screen. But if the data set is large, you can suppress the output by adding a semicolon (;) at the end of the line.

- ls

list content of directory

- cd('DIRECTORY_NAME')

changes directory to DIRECTORY_NAME

- addpath('DIRECTORY_NAME')

Loads programs defined in DIRECTORY_NAME

- A=load('FILE_NAME');

loads an Ascii file

- A=gread('FILE_NAME');

loads a binary file named FILE_NAME and places it in variable A

- gwrite('FILE_NAME',A);

loads a binary file named FILE_NAME and places it in variable A

- whos A

shows information of the matrix A, in particular its size

- B = A';

transposes matrix A in placed it in B

- B = reshape(A,[n m p]);

changes the dimension of matrix A in [n m p]

- pcolor(A), shading flat, colorbar

draws matrix A. The colors represent the values of the elements of A and the axis are the dimensions of the matrix

- find(A == 11);

finds the indexes of all elements of A equals to 11

- A(find(A == 11)) = NaN;

replace all elements in A equal to 11 to NaN

- B = squeeze(A);

remove the dimensions of size 1 of the matrix A and place the result in B

- % some explanation

lines starting with % are ignored. They are used to comment the program.