**format compact**- output without empty lines
**more on**- output one screen at a time
- Hint: put these lines in the file
`startup.m`in your working directory, and they will be automatically on in your sessions.

**sort(x), sort(A)**- sorts elements of vector x, or columns of matrix A

**eig(A)**- [V,E]=eig(A) gives the matrix V of eigenvectors and the matrix E of respective eigenvalues (in the diagonal) of matrix A.
- Notice: eigenvectors are in
*no particular order*.

**conv2(F,H)**- convolution F*H

**Some matrix operations**- For matrix A and scalar t,
- A>t returns a matrix B with B(i,j)=1, if A(i,j)>t, and B(i,j)=0 otherwise. Similarly for >,>=,<=,==,~= operations.
- max(A,t) returns the matrix similar to A, but elements smaller than t are set to t; min(A,t) does the opposite.

**Three and more dimensional matrices**- An example tells it all:
>> D(:,:,1)=ones(3,3); >> D(:,:,2)=zeros(3,3); >> D(:,:,3)=diag(1:3); >> D D(:,:,1) = 1 1 1 1 1 1 1 1 1 D(:,:,2) = 0 0 0 0 0 0 0 0 0 D(:,:,3) = 1 0 0 0 2 0 0 0 3

- Notice: Limited set of aritmetic operations.

**size(x)****size(A)****size(A,n)**- Returns size of a vector, matrix or nth level of NDIM matrix.

**squeeze(X)**- For example:
`squeeze(D(2,2,:))`is`[1 0 2]'`in the example above. Otherwise:>> D(2,2,:) ans(:,:,1) = 1 ans(:,:,2) = 0 ans(:,:,3) = 2

**image(I)**- Shows a matrix as an image;

- if the dimension of the matrix is MxX,`image`uses**colormap**

- if MxXx3,`image`treats it as an RGB image

**colormap([1:255; 1:255, 1:255])****colormap('gray')**- see
`help colormap`

**imread(filename)****imread(filename,format)**- I=imread('name.tif') reads a tif image to matrix I
- I=imread('name.im1',tif) reads a tif image to matrix I
- depending on image format, I becomes a conventional 2D matrix or a NDIM matrix with size(I,3)=3.
- Supported formats: bmp,hdf,jpg,pcx,xwd

**imshow(I,0:255)****imshow(I,[0 255])**- Shows a single channel image I in gray scale
**imshow(I,MAP)**- Shows an indexed-color image I with the colormap MAP
**imshow(I,MAP)**- Shows a true RGB image I in colors: red=I(:,:,1), green=I(:,:,2), blue=I(:,:,3)

**double(I)**- Converts a matrix to the double-precision floating-point format

**help****help help****help relops****help elmat****help images****help specgraph****help graph2d**

You are at: CIS → /Opinnot/T-61.5100/project/matcommands.shtml

Page maintained by webmaster at cis.hut.fi, last updated Monday, 12-Nov-2007 15:44:22 EET