You are on page 1of 18

INTRODUCTIO

N
TO MATLAB

INTRODUCTION
Matlab- which stands for MATrix LABoratory, is a highperformance language for technical computing.
It integrates computation, visualization, and programming
in an easy-to-use
environment where problems and solutions are expressed
in familiar
mathematical notation.

APPLICATION OF
MATLAB
Math and computation
Algorithm development
Data acquisition
Modeling, simulation, and prototyping
Data analysis, exploration, and visualization
Scientific and engineering graphics
Application development, including graphical user
interface building

MATLAB SYSTEM
Development Environment.
The MATLAB Mathematical Function Library.
The MATLAB Language.
Graphics.
The MATLAB Application Program Interface (API).

MATLAB INTERFACE
Command Window
type commands
Current Directory
View folders and m-files
Workspace
View program variables
Double click on a variable
to see it in the Array Editor

Command History
view past commands
save a whole session
using diary

Variables
No need for types. i.e.,
int a;
double b;
float c;

All variables are created with double precision unless


specified and they are matrices.

Example:
>>x=5;
>>x1=2;

Array, Matrix
a vector
x =
1
2

x = [1 2 5 1]

a matrix

z = [1 2 3; 5 1 4; 3 2 -1]

z =
1
5

2
1

3
4

transpose y

-1
= x

y =
1

2
5
1

Long Array, Matrix

t =1:10
t =

k =2:-0.5:-1
k =

1.5

0.5

= [1:4; 5:8]

B =
1
5

2
6

3
7

4
8

-0.5

-1

10

Generating Vectors from functions

Matrix Index

Operators (arithmetic)

Matrices Operations
Given A and B:

Addition

Subtraction

Product

Transpose

Operators (Element by
Element)

Operators (Element by Element)


a= a b

b= e f

c d

a.*b =
ae bf
cg dh

Basic Matrix Operations


Inv(A): inverse of A
Rank(A): rank of matrix A
A: transpose of A
Det(A): determinant
V= eig(A): eigenvalue vector of A
Size(A): return [m n]
Length(A): length of a vector
Length(A) = max(size(A))

Basic Matrix Operations


B = A(2:4,3:5)
B is the subset of A from row 2 to row 4, column 3 to column 5

A(:, 2)=[]
Delete second column

find(condition) - Returns indexes of As elements that satisfies


the condition.
A = [1 2; 3 4], I = find(A<4)
A=

1 2
3

I=1
2
3

Concatenation of
Matrices
x = [1 2], y = [4 5], z=[ 0 0]

A = [ x y]

B = [x ; y]

1 2
4 5

C = [x y ;z]
Error:
??? Error using ==> vertcat CAT arguments dimensions are not consistent.

You might also like