SlideShare uma empresa Scribd logo
1 de 98
MATLAB
Krishna K. Mohbey
Bhopal

MANIT
MATLAB introduction
MATLAB is a program for doing numerical
computation.
It was originally designed for solving linear
algebra type problems using matrices.
It’s name is derived from MATrix LABoratory.
MATLAB has since been expanded and now has
built-in functions for solving problems requiring
data analysis, signal processing, optimization, and
several other types of scientific computations.
It also contains functions for 2-D and 3-D graphics
and animation.
MATLAB
Matlab is basically a high level language which has
many specialized toolboxes for making things easier
for us
How high?
Matlab
High Level
Languages such as
C, Pascal etc.

Assembly
What are we interested in?
Matlab is too broad for our purposes in this
course.
The features we are going to require is
Matlab

Series of
Matlab
commands

m-files

Input
Output
capability

Command
Line

mat-files

functions
Command
execution like DOS
command window

Data
storage/
loading
Matlab Screen


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
MATLAB Help
• MATLAB Help is an extremely
powerful assistance to learning
MATLAB
• Help not only contains the
theoretical background, but also
shows demos for
implementation
• MATLAB Help can be opened
by using the HELP pull-down
menu
MATLAB Help (cont.)
• Any command description
can be found by typing the
command in the search field
• As shown above, the
command to take square
root (sqrt) is searched
• We can also utilize
MATLAB Help from the
command window as shown
MATLAB Toolboxes

















Statistics Toolbox
Optimization Toolbox
Database Toolbox
Parallel Computing Toolbox
Image Processing Toolbox
Bioinformatics Toolbox
Fuzzy Logic Toolbox
Neural Network Toolbox
Data Acquisition Toolbox
MATLAB Report Generator
Signal Processing
Communications
System Identification
Wavelet Filter Design
Control System
Robust Control
Connecting to MATLAB
C/C++
Java
Perl

Excel /
COM

Database
Toolbox

Web

Instrument Control
Data Acquisition
Image Acquisition

File I/O
Deploying with MATLAB

C/C++
Stand-alone

COM

Excel

Web
MATLAB
The MATLAB environment is command oriented
somewhat like UNIX.
A prompt appears on the screen and a MATLAB
statement can be entered.
When the <ENTER> key is pressed, the statement is
executed, and another prompt appears.
If a statement is terminated with a semicolon ( ; ), no
results will be displayed.
Otherwise results will appear before the next prompt.
The MATLAB User Interface
More about the Workspace
• who, whos – current variables in the
workspace
• save – save workspace variables to *.mat file
• load – load variables from *.mat file
• clear – clear workspace variables
- CODE
MATLAB

Everything in MATLAB is a matrix !
Starting MATLAB
To get started, type one of these commands:
helpwin, helpdesk, or demo
» a=5;
» b=a/2
b=
2.5000
»
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;

After these statements, the variables are 1x1 matrices with
double precision
MATLAB Variable Names
Variable names ARE case sensitive
Variable names can contain up to 63
characters (as of MATLAB 6.5 and newer)
Variable names must start with a letter
followed by letters, digits, and underscores.
MATLAB Special Variables
1.
2.
3.
4.
5.
6.
7.
8.

ans
pi
eps
inf
NaN
i and j
realmin
realmax

Default variable name for results
Value of π
Smallest incremental number
Infinity
Not a number e.g. 0/0
i = j = square root of -1
The smallest usable positive real number
The largest usable positive real number
Different format
>> e=1/3
e=
0.3333
>> format long
>> e
e=
0.333333333333333
>> format short e
>> e
e=
3.3333e-001

%default

%long decimal

%long exponential
To clear a variable
» who
Your variables are:
D
NRe

ans
mu

rho
v

» clear D
» who
Your variables are:
NRe

ans

mu

rho

v
Complex Numbers
Complex number i or j stands for √-1
»i
ans =
0 + 1.0000i
» c1 = 2+3i
c1 =
2.0000 + 3.0000i
»
Complex Numbers
Some functions deal with complex number
>> c=1-2i
c = 1.0000 - 2.0000i
>> abs(c)
ans =

2.2361

ans =

1

>> real(c)
>> imag(c)
ans = -2
>> angle(c)
ans = -1.1071
Mathematical Functions
» x=sqrt(2)/2
x=
0.7071
» y=sin(x)
y=
0.6496
»
Built-in Functions
Trigonometric
functions

Exponential
functions
Complex
functions
Rounding and
Remainder
functions

sin, cos, tan, sin, acos, atan,
sinh, cosh, tanh, asinh,
acosh, atanh, csc, sec, cot,
acsc, …
exp, log, log10, sqrt
abs, angle, imag, real, conj
floor, ceil, round, mod, rem,
sign
Math & Assignment Operators
Power
Multiplication
Division
or
NOTE:

^ or .^
a^b
* or .*
a*b
/ or ./
a/b
or . ba or
56/8 = 856

- (unary) + (unary)
Addition
+
Subtraction Assignment =

a+b
a-b
a=b

or
a.^b
or
a.*b
or
a./b
b.a

(assign b to a)
Other MATLAB symbols
>>
...
,
%
;
:

prompt
continue statement on next line
separate statements and data
start comment which ends at end of line
(1) suppress output
(2) used as a row separator in a matrix
specify range
MATLAB Relational Operators
MATLAB supports six relational operators.
Less Than
Less Than or Equal
Greater Than
Greater Than or Equal
Equal To
Not Equal To

<
<=
>
>=
==
~=
MATLAB Logical Operators
MATLAB supports three logical operators.
not
and
or

~
&
|

% highest precedence
% equal precedence with or
% equal precedence with and
MATLAB Matrices
MATLAB treats all variables as matrices. For our
purposes a matrix can be thought of as an array, in
fact, that is how it is stored.
Vectors are special forms of matrices and contain
only one row OR one column.
Scalars are matrices with only one row AND one
column
MATLAB Matrices
A matrix with only one row AND one column is a
scalar. A scalar can be created in MATLAB as
follows:
» x=23
x=
23
MATLAB Matrices
A matrix with only one row is called a row vector. A row
vector can be created in MATLAB as follows (note the
commas):
» rowvec = [12 , 14 , 63]
rowvec =
12

14

63
MATLAB Matrices
A matrix with only one column is called a column vector. A
column vector can be created in MATLAB as follows (note
the semicolons):
» colvec = [13 ; 45 ; -2]
colvec =
13
45
-2
MATLAB Matrices
A matrix can be created in MATLAB as follows (note the
commas AND semicolons):
» a = [1 , 2 , 3 ; 4 , 5 ,6 ; 7 , 8 , 9]
Or
» a = [1 2 3 ; 4 5 6 ; 7 8 9]
Or
>> a=[1 2 3
456
7 8 9]
a=
1
4
7

2
5
8

3
6
9
Extracting a Sub-Matrix
A portion of a matrix can be extracted and stored in a smaller
matrix by specifying the names of both matrices and the rows
and columns to extract. The syntax is:
sub_matrix = matrix ( r1 : r2 , c1 : c2 ) ;
where r1 and r2 specify the beginning and ending rows and c1
and c2 specify the beginning and ending columns to be
extracted to make the new matrix.
MATLAB Matrices


A column vector can be extracted
from a matrix. As an example
we create a matrix below:



Here we extract column 2 of the
matrix and make a column vector:

» matrix=[1,2,3;4,5,6;7,8,9]

» coltwo=matrix( : , 2)

matrix =
1 2
4 5
7 8

coltwo =
3
6
9

2
5
8
MATLAB Matrices
A row vector can be extracted
from a matrix. As an example
we create a matrix below:
» matrix=[1,2,3;4,5,6;7,8,9]

» rowvec=matrix(2 : 2 , 1 : 3)

matrix =
1
4
7

2
5
8

Here we extract row 2 of the
matrix and make a row vector.
Note that the 2:2 specifies the
second row and the 1:3 specifies
which columns of the row.

3
6
9

rowvec =
4

5

6
Special Matrices
1
eye(3) = 0

0

1
ones(3) = 1

1


0 0
1 0

0 1

1 1
1 1

1 1


0 0 
zeros(3,2) = 0 0


0 0 


1 1 1 1
ones(2,4) = 
1 1 1 1


Special Matrices functions
>> a=magic(4)

%magic matrix

a=
16 2
5 11
9 7
4 14

3 13
10 8
6 12
15 1

>> b=rand(5)

%random matrix

b=
0.8147
0.9058
0.1270
0.9134
0.6324

0.0975
0.2785
0.5469
0.9575
0.9649

0.1576
0.9706
0.9572
0.4854
0.8003

0.1419
0.4218
0.9157
0.7922
0.9595

0.6557
0.0357
0.8491
0.9340
0.6787
Some matrix building functions
>> a
>> a
a=
a=
1 2
1 2
4 5
4 5
7 8
7 8
>> diag(a)
ans =
1
5
9

>> triu(a)
ans =
1 2 3
0 5 6
0 0 9

3
3
6
6
9
9
>> tril(a)
ans =
1 0
4 5
7 8

0
0
9
Concatenation of Matrices


x = [1 2], y = [4 5]
A = [ x y]
1 2 4 5
B = [x ; y]
12
45
Matrices Operations

Given A and B:

Addition

Subtraction

Product

Transpose
Scalar - Matrix Addition
» a=3;
» b=[1, 2, 3;4, 5, 6]
b=
1 2 3
4 5 6
» c= b+a
% Add a to each element of b
c=
4 5 6
7 8 9
Scalar - Matrix Subtraction
» a=3;
» b=[1, 2, 3;4, 5, 6]
b=
1 2 3
4 5 6
»c=b-a
%Subtract a from each element of b
c=
-2 -1 0
1 2 3
Scalar - Matrix Multiplication
» a=3;
» b=[1, 2, 3; 4, 5, 6]
b=
1 2 3
4 5 6
»c=a*b
% Multiply each element of b by a
c=
3 6 9
12 15 18
Scalar - Matrix Division
» a=3;
» b=[1, 2, 3; 4, 5, 6]
b=
1 2 3
4 5 6
»c=b/a
% Divide each element of b by a
c=
0.3333 0.6667 1.0000
1.3333 1.6667 2.0000
The use of “.” – “Element” Operation
Given A:

Divide each
element of A by 2

Multiply each
element of A by
3

Square each
element of A
Mean and Median
Mean: Average or mean value of a distribution
Median: Middle value of a sorted distribution
M = mean(A),
M = mean(A,dim),

M = median(A)
M = median(A,dim)

M = mean(A), M = median(A): Returns the mean or median value of vector A.
If A is a multidimensional mean/median returns an array of mean values.
Example:
A = [ 0 2 5 7 20]

B = [1 2 3
336
468
4 7 7];

mean(A) = 6.8
mean(B) = 3.0000 4.5000 6.0000 (column-wise mean)
mean(B,2) = 2.0000 4.0000 6.0000 6.0000 (row-wise mean)
Mean and Median
Examples:

A = [ 0 2 5 7 20]

B = [1 2 3
336
468
4 7 7];

Mean:

mean(A) = 6.8
mean(B) = 3.0 4.5 6.0 (column-wise mean)
mean(B,2) = 2.0 4.0 6.0 6.0 (row-wise mean)
Median:

median(A) = 5
median(B) = 3.5 4.5 6.5 (column-wise median)
median(B,2) = 2.0
3.0
6.0
7.0 (row-wise median)
Standard Deviation and Variance








Standard deviation is calculated using the std() function
std(X) : Calcuate the standard deviation of vector x
If x is a matrix, std() will return the standard deviation of each column
Variance (defined as the square of the standard deviation) is calculated using
the var() function
var(X) : Calcuate the variance of vector x
If x is a matrix, var() will return the standard deviation of each column

X = [1 5 9;7 15 22]
s = std(X)
s = 4.2426 7.0711 9.1924
Histograms
•
•

Histograms are useful for showing the pattern of the
whole data set
Allows the shape of the distribution to be easily
visualized
Histograms
Matlab hist(y,m) command will generate a frequency histogram
of vector y distributed among m bins
Also can use hist(y,x) where x is a vector defining the bin
centers

Example:
>>b=sin(2*pi*t)
>>hist(b,10);

>>hist(b,[-1 -0.75 0 0.25 0.5 0.75
40

45
40

35

35

30

30

25

25

20
20

15
15

10
10

5

5
0
-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1

0
-1.5

-1

-0.5

0

0.5

1

1.5
Histograms
The histc function is a bit more powerful and allows bin edges to
be defined
[n, bin] = histc(x, binrange)
x = statistical distribution
binrange = the range of bins to plot e.g.: [1:1:10]
n = the number of elements in each bin from vector x
bin = the bin number each element of x belongs


Use the bar function to plot the histogram
Histograms
Example:
>> test = round(rand(100,1)*10)
>> histc(test,[1:1:10])
>> Bar(test)

14

12

10

8

6

4

2

0

1

2

3

4

5

6

7

8

9

10
Some Useful MATLAB commands
who
whos
help
lookfor
what
clear
clear x y
clc

List known variables
List known variables plus their size
>> help sqrt
Help on using sqrt
>> lookfor sqrt Search for
keyword sqrt in m-files
>> what a: List MATLAB files in a:
Clear all variables from work space
Clear variables x and y from work space
Clear the command window
Some Useful MATLAB commands
what
dir
ls
type test
delete test
cd a:
chdir a:
pwd

List all m-files in current directory
List all files in current directory
Same as dir
Display test.m in command window
Delete test.m
Change directory to a:
Same as cd
Show current directory
MATLAB Logical Functions
MATLAB also supports some logical functions.
xor (exclusive or)
Ex: xor (a, b)
Where a and b are logical expressions. The xor operator evaluates to
true if and only if one expression is true and the other is false.
True is returned as 1, false as 0.
any (x)
all (x)
isnan (x)
isinf (x)
finite (x)

returns 1 if any element of x is nonzero
returns 1 if all elements of x are nonzero
returns 1 at each NaN in x
returns 1 at each infinity in x
returns 1 at each finite value in x
Input and fprintf
>> x=input('please enter a number')
please enter a number100
x=
100
>> fprintf('%d',x)
100>>
>>
Text string,error message
Text string are entered into matlab surrounded by
single quotes
s=‘this is a text’
Text string can be displayed with
disp(‘this is message’)
Error message are best display with
error(‘sorry, this is error’)
Flow Control
if
for
while
switch case
break
….
Control Structures
If Statement Syntax
if (Condition_1)
Matlab Commands
elseif (Condition_2)
Matlab Commands
elseif (Condition_3)
Matlab Commands
else
Matlab Commands
end

Some Dummy Examples

if ((a>3) & (b==5))
Some Matlab Commands;
end
if (a<3)
Some Matlab Commands;
elseif (b~=5)
Some Matlab Commands;
end
if (a<3)
Some Matlab Commands;
else
Some Matlab Commands;
end
Control Structures
Some Dummy Examples

For loop syntax
for i=Index_Array
Matlab Commands
end
%................................
for i=start:inc_value:stop
Matlab Commands
end

for i=1:100
Some Matlab Commands;
end
for j=1:3:200
Some Matlab Commands;
end
for m=13:-0.2:-21
Some Matlab Commands;
end
for k=[0.1 0.3 -13 12 7 -9.3]
Some Matlab Commands;
end
Control Structures
While Loop Syntax
Dummy Example

while (condition)
Matlab Commands
end

while ((a>3) & (b==5))
Some Matlab Commands;
end
switch
• switch – Switch among several cases based on
expression
• The general form of SWITCH statement is:
switch switch_expr
case case_expr,

statement, …, statement
case {case_expr1, case_expr2, case_expr3, …}

statement, …, statement
…
otherwise

statement, …, statement
end
switch (cont.)
• Note:
– Only the statements between the matching CASE and
the next case, otherwise, or end are executed
– Unlike C, the switch statement does not fall
through (so breaks are unnecessary)

• CODE
Some Examples
>> x=20
x=

20

y=

30

>> y=30
>> if x>y
'greater x'
else
'greater y'
end
ans =greater y
>>
Some Examples
>> for p=1:10
fprintf('%dt',p)
end
1 2 3 4 5 6 7 8 9 10 >>

>> for p=1:2:10
fprintf('%dt',p)
end
1
3
5

7

9

>>
Reading Data from files
MATLAB supports reading an entire file and creating a matrix of
the data with one statement.
>> load fcmdata.dat;

% loads file into matrix.

% The matrix may be a scalar, a vector, or a
% matrix with multiple rows and columns. The
% matrix will be named mydata.

>> size (fcmdata)

>> length (fcmdata)

% size will return the number
% of rows and number of
% columns in the matrix
% length will return the total
% no. of elements in myvector
MATLAB Graphics
One of the best things about MATLAB is interactive
graphics
“plot” is the one you will be using most often
Many other 3D plotting functions -- plot3, mesh, surfc,
etc.
Use “help plot” for plotting options
To get a new figure, use “figure”
logarithmic plots available using semilogx, semilogy
and loglog
Plotting Commands
plot(x,y) defaults to a blue line
plot(x,y,’ro’) uses red circles
plot(x,y,’g*’) uses green asterisks
If you want to put two plots on the same graph, use
“hold on”
plot(a,b,’r:’)
hold on
plot(a,c,’ko’)

(red dotted line)
(black circles)
Color, Symbols, and Line Types
Use “help plot” to find available Specifiers
Colors

Symbols

Line Types

b

blue

.

point

-

solid

g

green

o

circle

:

dotted

r

red

x

x-mark

-.

dashdot

c

cyan

+

plus

--

dashed

m

magenta

*

star

y

yellow

s

square

k

black

d

diamond

v

triangle (down)

^

triangle (up)

<

triangle (left)

>

triangle (right)

p

pentagram

h

hexagram
Plotting
PLOT Linear plot.
PLOT(X,Y) plots vector Y
versus vector X
PLOT(Y) plots the columns of Y
versus their index
PLOT(X,Y,S) with plot symbols
and colors
See also SEMILOGX,
SEMILOGY, TITLE,
XLABEL, YLABEL, AXIS,
AXES, HOLD, COLORDEF,
LEGEND, SUBPLOT...

Example
x = [-3 -2 -1 0
1 2 3];
y1 = (x.^2) -1;
plot(x,
y1,'bo-.');
Plot Properties

XLABEL X-axis label.
XLABEL('text') adds text
beside the X-axis on the
current axis.

YLABEL Y-axis label.
YLABEL('text') adds text
beside the Y-axis on the
current axis.

Example
...
xlabel('x
values');
ylabel('y
values');
Hold

HOLD Hold current graph.
HOLD ON holds the current plot and
all axis properties so that subsequent
graphing commands add to the
existing graph.
HOLD OFF returns to the default
mode
HOLD, by itself, toggles the hold
state.

Example
...
hold on;
y2 = x + 2;
plot(x, y2,
'g+:');
Subplot
SUBPLOT Create axes in tiled positions.
SUBPLOT(m,n,p), or SUBPLOT(mnp),
breaks the Figure window into an m-by-n
matrix of small axes

Example
x = [-3 -2 -1 0 1 2 3];
y1 = (x.^2) -1;
% Plot y1 on the top
subplot(2,1,1);
plot(x, y1,'bo-.');
xlabel('x values');
ylabel('y values');
% Plot y2 on the bottom
subplot(2,1,2);
y2 = x + 2;
plot(x, y2, 'g+:');
Figure
FIGURE Create figure window.
FIGURE, by itself, creates a new
figure window, and returns its
handle.

Example
x = [-3 -2 -1 0 1 2 3];
y1 = (x.^2) -1;
% Plot y1 in the 1st Figure
plot(x, y1,'bo-.');
xlabel('x values');
ylabel('y values');
% Plot y2 in the 2nd Figure
figure
y2 = x + 2;
plot(x, y2, 'g+:');
Surface Plot
x = 0:0.1:2;
x = 0:0.1:2;
y = 0:0.1:2;
y = 0:0.1:2;
[xx, yy] = meshgrid(x,y);
[xx, yy] = meshgrid(x,y);
zz=sin(xx.^2+yy.^2);
zz=sin(xx.^2+yy.^2);
surf(xx,yy,zz)
surf(xx,yy,zz)
xlabel('X axes')
xlabel('X axes')
ylabel('Y axes')
ylabel('Y axes')
2D line plot
0.8
0.6
0.4
0.2
amplitude

>> x=0:0.05:5;
>> y=sin(x.^2);
>> plot(x,y);
>> xlabel('time');
>> plot(x,y);
>> xlabel('time');
>>ylabel('amplitude');

1

0
-0.2
-0.4
-0.6
-0.8
-1

0

0.5

1

1.5

2

2.5
time

3

3.5

4

4.5

5
Bar plot
>> x=-2.9:0.2:2.9;
>> bar(x,exp(-x.*x));
>>

1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
-3

-2

-1

0

1

2

3
Stairstep plot of sine wave
>> x=0:0.25:10;
>> stairs(x,sin(x));

1
0.8
0.6
0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
-1

0

1

2

3

4

5

6

7

8

9

10
M-Files
Script file: a collection of MATLAB commands
Function file: a definition file for one function
Script Files
Any valid sequence of MATLAB commands can
be in the script files.
Variables defined/used in script files are global,
i.e., they present in the workspace.
Using Script M-files
» what
M-files in the current directory
C:WINDOWSDesktopMatlab-Tutorials
abc abc1
» abc
1
3
5
.
.
.

File Name
M-file Example

%test.m
for i=1:5
for j=1:i
fprintf('*');
end
fprintf('n');
end

%output
>> test
*
**
***
****
*****
Writing User Defined Functions
Functions are m-files which can be executed by specifying some
inputs and supply some desired outputs.
The code telling the Matlab that an m-file is actually a function is

function out1=functionname(in1)
function out1=functionname(in1,in2,in3)
function [out1,out2]=functionname(in1,in2)
You should write this command at the beginning of the m-file and
you should save the m-file with a file name same as the function
name
Writing User Defined Functions
Examples
Write a function : out=squarer (A, ind)

Which takes the square of the input matrix if the input
indicator is equal to 1
And takes the element by element square of the input
matrix if the input indicator is equal to 2

Same Name
Writing User Defined Functions
Another function which takes an input array and returns the sum and product of its
elements as outputs

The function sumprod(.) can be called from command window or an m-file as
Function Example1
multiply.m
function y = multiply(a,b)
y=a*b;
end

output
>> multiply(23,3)
ans =
69
Function Example2
function1.m
function [out1,out2] = function1(a,b)
out1=sin(a);
out2=sin(b);
end

output
[a,b]=function1(2,4)
a=
0.9093
b=
-0.7568
Cluster Analysis?
Finding groups of objects such that the objects in a group will
be similar (or related) to one another and different from (or
unrelated to) the objects in other groups
Clustering techniques
Clustering
Clustering

Partitional
Partitional
k-mean

Hierarchical
Hierarchical

agglomerative

divisive
Hierarchical clustering
Algorithm Description

1. Determine the distance between each pair of
points
2. Iteratively group points into a binary
hierarchical cluster tree(linkage)
3. cut the hierarchical tree into cluster
Hierarchical clustering

1.
0.075

0.07

0.065

2.

0.06

0.055

0.05

2 28 7 24 27 21 18 12 6 9 15 26 10 3 8 29 5 17 22 13 30 16 1 23 4 11 20 19 25 14

3.
Hierarchical clustering using matlab
load fisheriris
X=meas
Y = pdist(X)
z=linkage(Y)
dendrogram(z)

0.075

0.07

0.065

0.06

0.055

0.05

2 28 7 24 27 21 18 12 6 9 15 26 10 3 8 29 5 17 22 13 30 16 1 23 4 11 20 19 25 14
Hierarchical clustering using matlab
7

load fisheriris
X=meas
Y = pdist(X)
z=linkage(Y)
dendrogram(z)
hidx=cluster(z,'MaxClust',3)
ptsymb = {'bs','r^','md','go','c+'};
for i=1:max(hidx)
clust=find(hidx==i)
plot3(X(clust,1),X(clust,2),X(clust,3),ptsymb{i});
hold on;
end
6
5
4
3
2

1
4.5

4

3.5

3

2.5

2

4

4.5

5

5.5

6

6.5

7

7.5

8
Thanks

Mais conteúdo relacionado

Mais procurados

MATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulink
MATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulinkMATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulink
MATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulinkreddyprasad reddyvari
 
MATLAB Basics-Part1
MATLAB Basics-Part1MATLAB Basics-Part1
MATLAB Basics-Part1Elaf A.Saeed
 
Basic matlab and matrix
Basic matlab and matrixBasic matlab and matrix
Basic matlab and matrixSaidur Rahman
 
Matlab matrices and arrays
Matlab matrices and arraysMatlab matrices and arrays
Matlab matrices and arraysAmeen San
 
An Introduction to MATLAB for beginners
An Introduction to MATLAB for beginnersAn Introduction to MATLAB for beginners
An Introduction to MATLAB for beginnersMurshida ck
 
Brief Introduction to Matlab
Brief  Introduction to MatlabBrief  Introduction to Matlab
Brief Introduction to MatlabTariq kanher
 
Introduction to Matlab
Introduction to MatlabIntroduction to Matlab
Introduction to Matlabaman gupta
 
Introduction to MATLAB
Introduction to MATLABIntroduction to MATLAB
Introduction to MATLABRavikiran A
 
Matlab introduction
Matlab introductionMatlab introduction
Matlab introductionAmeen San
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabTarun Gehlot
 
Introduction to Matlab
Introduction to MatlabIntroduction to Matlab
Introduction to MatlabAmr Rashed
 
Matlab for beginners, Introduction, signal processing
Matlab for beginners, Introduction, signal processingMatlab for beginners, Introduction, signal processing
Matlab for beginners, Introduction, signal processingDr. Manjunatha. P
 
Introduction to MATLAB
Introduction to MATLABIntroduction to MATLAB
Introduction to MATLABAshish Meshram
 
Matlab (Presentation on MATLAB)
Matlab (Presentation on MATLAB)Matlab (Presentation on MATLAB)
Matlab (Presentation on MATLAB)Chetan Allapur
 
Matlab Introduction
Matlab IntroductionMatlab Introduction
Matlab IntroductionDaniel Moore
 

Mais procurados (20)

MATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulink
MATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulinkMATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulink
MATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulink
 
MATLAB Basics-Part1
MATLAB Basics-Part1MATLAB Basics-Part1
MATLAB Basics-Part1
 
Basic matlab and matrix
Basic matlab and matrixBasic matlab and matrix
Basic matlab and matrix
 
Matlab matrices and arrays
Matlab matrices and arraysMatlab matrices and arrays
Matlab matrices and arrays
 
An Introduction to MATLAB for beginners
An Introduction to MATLAB for beginnersAn Introduction to MATLAB for beginners
An Introduction to MATLAB for beginners
 
MATLAB - Arrays and Matrices
MATLAB - Arrays and MatricesMATLAB - Arrays and Matrices
MATLAB - Arrays and Matrices
 
Matlab basic and image
Matlab basic and imageMatlab basic and image
Matlab basic and image
 
Brief Introduction to Matlab
Brief  Introduction to MatlabBrief  Introduction to Matlab
Brief Introduction to Matlab
 
Introduction to Matlab
Introduction to MatlabIntroduction to Matlab
Introduction to Matlab
 
Introduction to MATLAB
Introduction to MATLABIntroduction to MATLAB
Introduction to MATLAB
 
Matlab introduction
Matlab introductionMatlab introduction
Matlab introduction
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
2D Plot Matlab
2D Plot Matlab2D Plot Matlab
2D Plot Matlab
 
Introduction to Matlab
Introduction to MatlabIntroduction to Matlab
Introduction to Matlab
 
Seminar on MATLAB
Seminar on MATLABSeminar on MATLAB
Seminar on MATLAB
 
Matlab for beginners, Introduction, signal processing
Matlab for beginners, Introduction, signal processingMatlab for beginners, Introduction, signal processing
Matlab for beginners, Introduction, signal processing
 
Introduction to MATLAB
Introduction to MATLABIntroduction to MATLAB
Introduction to MATLAB
 
Matlab (Presentation on MATLAB)
Matlab (Presentation on MATLAB)Matlab (Presentation on MATLAB)
Matlab (Presentation on MATLAB)
 
MATLAB Programming
MATLAB Programming MATLAB Programming
MATLAB Programming
 
Matlab Introduction
Matlab IntroductionMatlab Introduction
Matlab Introduction
 

Destaque

Advanced MATLAB Tutorial for Engineers & Scientists
Advanced MATLAB Tutorial for Engineers & ScientistsAdvanced MATLAB Tutorial for Engineers & Scientists
Advanced MATLAB Tutorial for Engineers & ScientistsRay Phan
 
B61301007 matlab documentation
B61301007 matlab documentationB61301007 matlab documentation
B61301007 matlab documentationManchireddy Reddy
 
Matlab for Electrical Engineers
Matlab for Electrical EngineersMatlab for Electrical Engineers
Matlab for Electrical EngineersManish Joshi
 
MATLAB Programs For Beginners. | Abhi Sharma
MATLAB Programs For Beginners. | Abhi SharmaMATLAB Programs For Beginners. | Abhi Sharma
MATLAB Programs For Beginners. | Abhi SharmaAbee Sharma
 
MATLAB Modeling of SPT and Grain Size Data in Producing Soil Profile
MATLAB Modeling of SPT and Grain Size Data in Producing Soil ProfileMATLAB Modeling of SPT and Grain Size Data in Producing Soil Profile
MATLAB Modeling of SPT and Grain Size Data in Producing Soil ProfilePsychōjit MØmz
 
Importance of matlab
Importance of matlabImportance of matlab
Importance of matlabkrajeshk1980
 
Matlab Mech Eee Lectures 1
Matlab Mech Eee Lectures 1Matlab Mech Eee Lectures 1
Matlab Mech Eee Lectures 1Ayyarao T S L V
 
Factorization from Gaussian Elimination
  Factorization from Gaussian Elimination  Factorization from Gaussian Elimination
Factorization from Gaussian EliminationMudassir Parvi
 
An introduction to FACTS
An introduction to FACTSAn introduction to FACTS
An introduction to FACTSAyyarao T S L V
 
Gauss Elimination Method With Partial Pivoting
Gauss Elimination Method With Partial PivotingGauss Elimination Method With Partial Pivoting
Gauss Elimination Method With Partial PivotingSM. Aurnob
 
Power Flow in a Transmission line
Power Flow in a Transmission linePower Flow in a Transmission line
Power Flow in a Transmission lineAyyarao T S L V
 
Matlab Mech Eee Lectures 1
Matlab Mech Eee Lectures 1Matlab Mech Eee Lectures 1
Matlab Mech Eee Lectures 1Ayyarao T S L V
 
Static shunt compensation
Static shunt compensationStatic shunt compensation
Static shunt compensationAyyarao T S L V
 
An introduction to FACTS Technology
An introduction to FACTS TechnologyAn introduction to FACTS Technology
An introduction to FACTS TechnologyAyyarao T S L V
 
Introduction to MATLAB
Introduction to MATLABIntroduction to MATLAB
Introduction to MATLABBhavesh Shah
 
Simulink - Introduction with Practical Example
Simulink - Introduction with Practical ExampleSimulink - Introduction with Practical Example
Simulink - Introduction with Practical ExampleKamran Gillani
 

Destaque (20)

Advanced MATLAB Tutorial for Engineers & Scientists
Advanced MATLAB Tutorial for Engineers & ScientistsAdvanced MATLAB Tutorial for Engineers & Scientists
Advanced MATLAB Tutorial for Engineers & Scientists
 
B61301007 matlab documentation
B61301007 matlab documentationB61301007 matlab documentation
B61301007 matlab documentation
 
Matlab
MatlabMatlab
Matlab
 
Matlab for Electrical Engineers
Matlab for Electrical EngineersMatlab for Electrical Engineers
Matlab for Electrical Engineers
 
MATLAB Programs For Beginners. | Abhi Sharma
MATLAB Programs For Beginners. | Abhi SharmaMATLAB Programs For Beginners. | Abhi Sharma
MATLAB Programs For Beginners. | Abhi Sharma
 
MATLAB Modeling of SPT and Grain Size Data in Producing Soil Profile
MATLAB Modeling of SPT and Grain Size Data in Producing Soil ProfileMATLAB Modeling of SPT and Grain Size Data in Producing Soil Profile
MATLAB Modeling of SPT and Grain Size Data in Producing Soil Profile
 
Importance of matlab
Importance of matlabImportance of matlab
Importance of matlab
 
Gráficas en matlab
Gráficas en matlabGráficas en matlab
Gráficas en matlab
 
Matlab Mech Eee Lectures 1
Matlab Mech Eee Lectures 1Matlab Mech Eee Lectures 1
Matlab Mech Eee Lectures 1
 
Factorization from Gaussian Elimination
  Factorization from Gaussian Elimination  Factorization from Gaussian Elimination
Factorization from Gaussian Elimination
 
An introduction to FACTS
An introduction to FACTSAn introduction to FACTS
An introduction to FACTS
 
Gauss Elimination Method With Partial Pivoting
Gauss Elimination Method With Partial PivotingGauss Elimination Method With Partial Pivoting
Gauss Elimination Method With Partial Pivoting
 
Power Flow in a Transmission line
Power Flow in a Transmission linePower Flow in a Transmission line
Power Flow in a Transmission line
 
Matlab Mech Eee Lectures 1
Matlab Mech Eee Lectures 1Matlab Mech Eee Lectures 1
Matlab Mech Eee Lectures 1
 
Static shunt compensation
Static shunt compensationStatic shunt compensation
Static shunt compensation
 
Matlab programs
Matlab programsMatlab programs
Matlab programs
 
Ballas1
Ballas1Ballas1
Ballas1
 
An introduction to FACTS Technology
An introduction to FACTS TechnologyAn introduction to FACTS Technology
An introduction to FACTS Technology
 
Introduction to MATLAB
Introduction to MATLABIntroduction to MATLAB
Introduction to MATLAB
 
Simulink - Introduction with Practical Example
Simulink - Introduction with Practical ExampleSimulink - Introduction with Practical Example
Simulink - Introduction with Practical Example
 

Semelhante a Matlab practical and lab session

MATLAB Workshop yugjjnhhasfhlhhlllhl.pptx
MATLAB Workshop yugjjnhhasfhlhhlllhl.pptxMATLAB Workshop yugjjnhhasfhlhhlllhl.pptx
MATLAB Workshop yugjjnhhasfhlhhlllhl.pptxprashantkumarchinama
 
From zero to MATLAB hero: Mastering the basics and beyond
From zero to MATLAB hero: Mastering the basics and beyondFrom zero to MATLAB hero: Mastering the basics and beyond
From zero to MATLAB hero: Mastering the basics and beyondMahuaPal6
 
matlab-130408153714-phpapp02_lab123.ppsx
matlab-130408153714-phpapp02_lab123.ppsxmatlab-130408153714-phpapp02_lab123.ppsx
matlab-130408153714-phpapp02_lab123.ppsxlekhacce
 
1.1Introduction to matlab.pptx
1.1Introduction to matlab.pptx1.1Introduction to matlab.pptx
1.1Introduction to matlab.pptxBeheraA
 
Matlab ch1 intro
Matlab ch1 introMatlab ch1 intro
Matlab ch1 introRagu Nathan
 
interfacing matlab with embedded systems
interfacing matlab with embedded systemsinterfacing matlab with embedded systems
interfacing matlab with embedded systemsRaghav Shetty
 
Introduction to matlab lecture 1 of 4
Introduction to matlab lecture 1 of 4Introduction to matlab lecture 1 of 4
Introduction to matlab lecture 1 of 4Randa Elanwar
 
Introduction to Matlab.pdf
Introduction to Matlab.pdfIntroduction to Matlab.pdf
Introduction to Matlab.pdfssuser43b38e
 

Semelhante a Matlab practical and lab session (20)

Matlab introduction
Matlab introductionMatlab introduction
Matlab introduction
 
Introduction to Matlab.ppt
Introduction to Matlab.pptIntroduction to Matlab.ppt
Introduction to Matlab.ppt
 
Matlab anilkumar
Matlab  anilkumarMatlab  anilkumar
Matlab anilkumar
 
MATLAB Workshop yugjjnhhasfhlhhlllhl.pptx
MATLAB Workshop yugjjnhhasfhlhhlllhl.pptxMATLAB Workshop yugjjnhhasfhlhhlllhl.pptx
MATLAB Workshop yugjjnhhasfhlhhlllhl.pptx
 
From zero to MATLAB hero: Mastering the basics and beyond
From zero to MATLAB hero: Mastering the basics and beyondFrom zero to MATLAB hero: Mastering the basics and beyond
From zero to MATLAB hero: Mastering the basics and beyond
 
Matlab summary
Matlab summaryMatlab summary
Matlab summary
 
MatlabIntro (1).ppt
MatlabIntro (1).pptMatlabIntro (1).ppt
MatlabIntro (1).ppt
 
Matlab tut2
Matlab tut2Matlab tut2
Matlab tut2
 
matlab-130408153714-phpapp02_lab123.ppsx
matlab-130408153714-phpapp02_lab123.ppsxmatlab-130408153714-phpapp02_lab123.ppsx
matlab-130408153714-phpapp02_lab123.ppsx
 
Matlab booklet
Matlab bookletMatlab booklet
Matlab booklet
 
Matlab introduction
Matlab introductionMatlab introduction
Matlab introduction
 
Matlab guide
Matlab guideMatlab guide
Matlab guide
 
1.1Introduction to matlab.pptx
1.1Introduction to matlab.pptx1.1Introduction to matlab.pptx
1.1Introduction to matlab.pptx
 
Matlab ch1 intro
Matlab ch1 introMatlab ch1 intro
Matlab ch1 intro
 
interfacing matlab with embedded systems
interfacing matlab with embedded systemsinterfacing matlab with embedded systems
interfacing matlab with embedded systems
 
Introduction to matlab lecture 1 of 4
Introduction to matlab lecture 1 of 4Introduction to matlab lecture 1 of 4
Introduction to matlab lecture 1 of 4
 
Introduction to Matlab.pdf
Introduction to Matlab.pdfIntroduction to Matlab.pdf
Introduction to Matlab.pdf
 
EE6711 Power System Simulation Lab manual
EE6711 Power System Simulation Lab manualEE6711 Power System Simulation Lab manual
EE6711 Power System Simulation Lab manual
 
Matlab Tutorial.ppt
Matlab Tutorial.pptMatlab Tutorial.ppt
Matlab Tutorial.ppt
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 

Último

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 

Último (20)

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 

Matlab practical and lab session

  • 2. MATLAB introduction MATLAB is a program for doing numerical computation. It was originally designed for solving linear algebra type problems using matrices. It’s name is derived from MATrix LABoratory. MATLAB has since been expanded and now has built-in functions for solving problems requiring data analysis, signal processing, optimization, and several other types of scientific computations. It also contains functions for 2-D and 3-D graphics and animation.
  • 3. MATLAB Matlab is basically a high level language which has many specialized toolboxes for making things easier for us How high? Matlab High Level Languages such as C, Pascal etc. Assembly
  • 4. What are we interested in? Matlab is too broad for our purposes in this course. The features we are going to require is Matlab Series of Matlab commands m-files Input Output capability Command Line mat-files functions Command execution like DOS command window Data storage/ loading
  • 5. Matlab Screen  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
  • 6. MATLAB Help • MATLAB Help is an extremely powerful assistance to learning MATLAB • Help not only contains the theoretical background, but also shows demos for implementation • MATLAB Help can be opened by using the HELP pull-down menu
  • 7. MATLAB Help (cont.) • Any command description can be found by typing the command in the search field • As shown above, the command to take square root (sqrt) is searched • We can also utilize MATLAB Help from the command window as shown
  • 8. MATLAB Toolboxes                 Statistics Toolbox Optimization Toolbox Database Toolbox Parallel Computing Toolbox Image Processing Toolbox Bioinformatics Toolbox Fuzzy Logic Toolbox Neural Network Toolbox Data Acquisition Toolbox MATLAB Report Generator Signal Processing Communications System Identification Wavelet Filter Design Control System Robust Control
  • 9. Connecting to MATLAB C/C++ Java Perl Excel / COM Database Toolbox Web Instrument Control Data Acquisition Image Acquisition File I/O
  • 11. MATLAB The MATLAB environment is command oriented somewhat like UNIX. A prompt appears on the screen and a MATLAB statement can be entered. When the <ENTER> key is pressed, the statement is executed, and another prompt appears. If a statement is terminated with a semicolon ( ; ), no results will be displayed. Otherwise results will appear before the next prompt.
  • 12. The MATLAB User Interface
  • 13. More about the Workspace • who, whos – current variables in the workspace • save – save workspace variables to *.mat file • load – load variables from *.mat file • clear – clear workspace variables - CODE
  • 15. Starting MATLAB To get started, type one of these commands: helpwin, helpdesk, or demo » a=5; » b=a/2 b= 2.5000 »
  • 16. 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; After these statements, the variables are 1x1 matrices with double precision
  • 17. MATLAB Variable Names Variable names ARE case sensitive Variable names can contain up to 63 characters (as of MATLAB 6.5 and newer) Variable names must start with a letter followed by letters, digits, and underscores.
  • 18. MATLAB Special Variables 1. 2. 3. 4. 5. 6. 7. 8. ans pi eps inf NaN i and j realmin realmax Default variable name for results Value of π Smallest incremental number Infinity Not a number e.g. 0/0 i = j = square root of -1 The smallest usable positive real number The largest usable positive real number
  • 19. Different format >> e=1/3 e= 0.3333 >> format long >> e e= 0.333333333333333 >> format short e >> e e= 3.3333e-001 %default %long decimal %long exponential
  • 20. To clear a variable » who Your variables are: D NRe ans mu rho v » clear D » who Your variables are: NRe ans mu rho v
  • 21. Complex Numbers Complex number i or j stands for √-1 »i ans = 0 + 1.0000i » c1 = 2+3i c1 = 2.0000 + 3.0000i »
  • 22. Complex Numbers Some functions deal with complex number >> c=1-2i c = 1.0000 - 2.0000i >> abs(c) ans = 2.2361 ans = 1 >> real(c) >> imag(c) ans = -2 >> angle(c) ans = -1.1071
  • 24. Built-in Functions Trigonometric functions Exponential functions Complex functions Rounding and Remainder functions sin, cos, tan, sin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh, csc, sec, cot, acsc, … exp, log, log10, sqrt abs, angle, imag, real, conj floor, ceil, round, mod, rem, sign
  • 25. Math & Assignment Operators Power Multiplication Division or NOTE: ^ or .^ a^b * or .* a*b / or ./ a/b or . ba or 56/8 = 856 - (unary) + (unary) Addition + Subtraction Assignment = a+b a-b a=b or a.^b or a.*b or a./b b.a (assign b to a)
  • 26. Other MATLAB symbols >> ... , % ; : prompt continue statement on next line separate statements and data start comment which ends at end of line (1) suppress output (2) used as a row separator in a matrix specify range
  • 27. MATLAB Relational Operators MATLAB supports six relational operators. Less Than Less Than or Equal Greater Than Greater Than or Equal Equal To Not Equal To < <= > >= == ~=
  • 28. MATLAB Logical Operators MATLAB supports three logical operators. not and or ~ & | % highest precedence % equal precedence with or % equal precedence with and
  • 29. MATLAB Matrices MATLAB treats all variables as matrices. For our purposes a matrix can be thought of as an array, in fact, that is how it is stored. Vectors are special forms of matrices and contain only one row OR one column. Scalars are matrices with only one row AND one column
  • 30. MATLAB Matrices A matrix with only one row AND one column is a scalar. A scalar can be created in MATLAB as follows: » x=23 x= 23
  • 31. MATLAB Matrices A matrix with only one row is called a row vector. A row vector can be created in MATLAB as follows (note the commas): » rowvec = [12 , 14 , 63] rowvec = 12 14 63
  • 32. MATLAB Matrices A matrix with only one column is called a column vector. A column vector can be created in MATLAB as follows (note the semicolons): » colvec = [13 ; 45 ; -2] colvec = 13 45 -2
  • 33. MATLAB Matrices A matrix can be created in MATLAB as follows (note the commas AND semicolons): » a = [1 , 2 , 3 ; 4 , 5 ,6 ; 7 , 8 , 9] Or » a = [1 2 3 ; 4 5 6 ; 7 8 9] Or >> a=[1 2 3 456 7 8 9] a= 1 4 7 2 5 8 3 6 9
  • 34. Extracting a Sub-Matrix A portion of a matrix can be extracted and stored in a smaller matrix by specifying the names of both matrices and the rows and columns to extract. The syntax is: sub_matrix = matrix ( r1 : r2 , c1 : c2 ) ; where r1 and r2 specify the beginning and ending rows and c1 and c2 specify the beginning and ending columns to be extracted to make the new matrix.
  • 35. MATLAB Matrices  A column vector can be extracted from a matrix. As an example we create a matrix below:  Here we extract column 2 of the matrix and make a column vector: » matrix=[1,2,3;4,5,6;7,8,9] » coltwo=matrix( : , 2) matrix = 1 2 4 5 7 8 coltwo = 3 6 9 2 5 8
  • 36. MATLAB Matrices A row vector can be extracted from a matrix. As an example we create a matrix below: » matrix=[1,2,3;4,5,6;7,8,9] » rowvec=matrix(2 : 2 , 1 : 3) matrix = 1 4 7 2 5 8 Here we extract row 2 of the matrix and make a row vector. Note that the 2:2 specifies the second row and the 1:3 specifies which columns of the row. 3 6 9 rowvec = 4 5 6
  • 37. Special Matrices 1 eye(3) = 0  0  1 ones(3) = 1  1  0 0 1 0  0 1  1 1 1 1  1 1  0 0  zeros(3,2) = 0 0   0 0    1 1 1 1 ones(2,4) =  1 1 1 1  
  • 38. Special Matrices functions >> a=magic(4) %magic matrix a= 16 2 5 11 9 7 4 14 3 13 10 8 6 12 15 1 >> b=rand(5) %random matrix b= 0.8147 0.9058 0.1270 0.9134 0.6324 0.0975 0.2785 0.5469 0.9575 0.9649 0.1576 0.9706 0.9572 0.4854 0.8003 0.1419 0.4218 0.9157 0.7922 0.9595 0.6557 0.0357 0.8491 0.9340 0.6787
  • 39. Some matrix building functions >> a >> a a= a= 1 2 1 2 4 5 4 5 7 8 7 8 >> diag(a) ans = 1 5 9 >> triu(a) ans = 1 2 3 0 5 6 0 0 9 3 3 6 6 9 9 >> tril(a) ans = 1 0 4 5 7 8 0 0 9
  • 40. Concatenation of Matrices  x = [1 2], y = [4 5] A = [ x y] 1 2 4 5 B = [x ; y] 12 45
  • 41. Matrices Operations Given A and B: Addition Subtraction Product Transpose
  • 42. Scalar - Matrix Addition » a=3; » b=[1, 2, 3;4, 5, 6] b= 1 2 3 4 5 6 » c= b+a % Add a to each element of b c= 4 5 6 7 8 9
  • 43. Scalar - Matrix Subtraction » a=3; » b=[1, 2, 3;4, 5, 6] b= 1 2 3 4 5 6 »c=b-a %Subtract a from each element of b c= -2 -1 0 1 2 3
  • 44. Scalar - Matrix Multiplication » a=3; » b=[1, 2, 3; 4, 5, 6] b= 1 2 3 4 5 6 »c=a*b % Multiply each element of b by a c= 3 6 9 12 15 18
  • 45. Scalar - Matrix Division » a=3; » b=[1, 2, 3; 4, 5, 6] b= 1 2 3 4 5 6 »c=b/a % Divide each element of b by a c= 0.3333 0.6667 1.0000 1.3333 1.6667 2.0000
  • 46. The use of “.” – “Element” Operation Given A: Divide each element of A by 2 Multiply each element of A by 3 Square each element of A
  • 47. Mean and Median Mean: Average or mean value of a distribution Median: Middle value of a sorted distribution M = mean(A), M = mean(A,dim), M = median(A) M = median(A,dim) M = mean(A), M = median(A): Returns the mean or median value of vector A. If A is a multidimensional mean/median returns an array of mean values. Example: A = [ 0 2 5 7 20] B = [1 2 3 336 468 4 7 7]; mean(A) = 6.8 mean(B) = 3.0000 4.5000 6.0000 (column-wise mean) mean(B,2) = 2.0000 4.0000 6.0000 6.0000 (row-wise mean)
  • 48. Mean and Median Examples: A = [ 0 2 5 7 20] B = [1 2 3 336 468 4 7 7]; Mean: mean(A) = 6.8 mean(B) = 3.0 4.5 6.0 (column-wise mean) mean(B,2) = 2.0 4.0 6.0 6.0 (row-wise mean) Median: median(A) = 5 median(B) = 3.5 4.5 6.5 (column-wise median) median(B,2) = 2.0 3.0 6.0 7.0 (row-wise median)
  • 49. Standard Deviation and Variance       Standard deviation is calculated using the std() function std(X) : Calcuate the standard deviation of vector x If x is a matrix, std() will return the standard deviation of each column Variance (defined as the square of the standard deviation) is calculated using the var() function var(X) : Calcuate the variance of vector x If x is a matrix, var() will return the standard deviation of each column X = [1 5 9;7 15 22] s = std(X) s = 4.2426 7.0711 9.1924
  • 50. Histograms • • Histograms are useful for showing the pattern of the whole data set Allows the shape of the distribution to be easily visualized
  • 51. Histograms Matlab hist(y,m) command will generate a frequency histogram of vector y distributed among m bins Also can use hist(y,x) where x is a vector defining the bin centers Example: >>b=sin(2*pi*t) >>hist(b,10); >>hist(b,[-1 -0.75 0 0.25 0.5 0.75 40 45 40 35 35 30 30 25 25 20 20 15 15 10 10 5 5 0 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1 0 -1.5 -1 -0.5 0 0.5 1 1.5
  • 52. Histograms The histc function is a bit more powerful and allows bin edges to be defined [n, bin] = histc(x, binrange) x = statistical distribution binrange = the range of bins to plot e.g.: [1:1:10] n = the number of elements in each bin from vector x bin = the bin number each element of x belongs  Use the bar function to plot the histogram
  • 53. Histograms Example: >> test = round(rand(100,1)*10) >> histc(test,[1:1:10]) >> Bar(test) 14 12 10 8 6 4 2 0 1 2 3 4 5 6 7 8 9 10
  • 54. Some Useful MATLAB commands who whos help lookfor what clear clear x y clc List known variables List known variables plus their size >> help sqrt Help on using sqrt >> lookfor sqrt Search for keyword sqrt in m-files >> what a: List MATLAB files in a: Clear all variables from work space Clear variables x and y from work space Clear the command window
  • 55. Some Useful MATLAB commands what dir ls type test delete test cd a: chdir a: pwd List all m-files in current directory List all files in current directory Same as dir Display test.m in command window Delete test.m Change directory to a: Same as cd Show current directory
  • 56. MATLAB Logical Functions MATLAB also supports some logical functions. xor (exclusive or) Ex: xor (a, b) Where a and b are logical expressions. The xor operator evaluates to true if and only if one expression is true and the other is false. True is returned as 1, false as 0. any (x) all (x) isnan (x) isinf (x) finite (x) returns 1 if any element of x is nonzero returns 1 if all elements of x are nonzero returns 1 at each NaN in x returns 1 at each infinity in x returns 1 at each finite value in x
  • 57. Input and fprintf >> x=input('please enter a number') please enter a number100 x= 100 >> fprintf('%d',x) 100>> >>
  • 58. Text string,error message Text string are entered into matlab surrounded by single quotes s=‘this is a text’ Text string can be displayed with disp(‘this is message’) Error message are best display with error(‘sorry, this is error’)
  • 60. Control Structures If Statement Syntax if (Condition_1) Matlab Commands elseif (Condition_2) Matlab Commands elseif (Condition_3) Matlab Commands else Matlab Commands end Some Dummy Examples if ((a>3) & (b==5)) Some Matlab Commands; end if (a<3) Some Matlab Commands; elseif (b~=5) Some Matlab Commands; end if (a<3) Some Matlab Commands; else Some Matlab Commands; end
  • 61. Control Structures Some Dummy Examples For loop syntax for i=Index_Array Matlab Commands end %................................ for i=start:inc_value:stop Matlab Commands end for i=1:100 Some Matlab Commands; end for j=1:3:200 Some Matlab Commands; end for m=13:-0.2:-21 Some Matlab Commands; end for k=[0.1 0.3 -13 12 7 -9.3] Some Matlab Commands; end
  • 62. Control Structures While Loop Syntax Dummy Example while (condition) Matlab Commands end while ((a>3) & (b==5)) Some Matlab Commands; end
  • 63. switch • switch – Switch among several cases based on expression • The general form of SWITCH statement is: switch switch_expr case case_expr, statement, …, statement case {case_expr1, case_expr2, case_expr3, …} statement, …, statement … otherwise statement, …, statement end
  • 64. switch (cont.) • Note: – Only the statements between the matching CASE and the next case, otherwise, or end are executed – Unlike C, the switch statement does not fall through (so breaks are unnecessary) • CODE
  • 65. Some Examples >> x=20 x= 20 y= 30 >> y=30 >> if x>y 'greater x' else 'greater y' end ans =greater y >>
  • 66. Some Examples >> for p=1:10 fprintf('%dt',p) end 1 2 3 4 5 6 7 8 9 10 >> >> for p=1:2:10 fprintf('%dt',p) end 1 3 5 7 9 >>
  • 67. Reading Data from files MATLAB supports reading an entire file and creating a matrix of the data with one statement. >> load fcmdata.dat; % loads file into matrix. % The matrix may be a scalar, a vector, or a % matrix with multiple rows and columns. The % matrix will be named mydata. >> size (fcmdata) >> length (fcmdata) % size will return the number % of rows and number of % columns in the matrix % length will return the total % no. of elements in myvector
  • 68. MATLAB Graphics One of the best things about MATLAB is interactive graphics “plot” is the one you will be using most often Many other 3D plotting functions -- plot3, mesh, surfc, etc. Use “help plot” for plotting options To get a new figure, use “figure” logarithmic plots available using semilogx, semilogy and loglog
  • 69. Plotting Commands plot(x,y) defaults to a blue line plot(x,y,’ro’) uses red circles plot(x,y,’g*’) uses green asterisks If you want to put two plots on the same graph, use “hold on” plot(a,b,’r:’) hold on plot(a,c,’ko’) (red dotted line) (black circles)
  • 70. Color, Symbols, and Line Types Use “help plot” to find available Specifiers Colors Symbols Line Types b blue . point - solid g green o circle : dotted r red x x-mark -. dashdot c cyan + plus -- dashed m magenta * star y yellow s square k black d diamond v triangle (down) ^ triangle (up) < triangle (left) > triangle (right) p pentagram h hexagram
  • 71. Plotting PLOT Linear plot. PLOT(X,Y) plots vector Y versus vector X PLOT(Y) plots the columns of Y versus their index PLOT(X,Y,S) with plot symbols and colors See also SEMILOGX, SEMILOGY, TITLE, XLABEL, YLABEL, AXIS, AXES, HOLD, COLORDEF, LEGEND, SUBPLOT... Example x = [-3 -2 -1 0 1 2 3]; y1 = (x.^2) -1; plot(x, y1,'bo-.');
  • 72. Plot Properties XLABEL X-axis label. XLABEL('text') adds text beside the X-axis on the current axis. YLABEL Y-axis label. YLABEL('text') adds text beside the Y-axis on the current axis. Example ... xlabel('x values'); ylabel('y values');
  • 73. Hold HOLD Hold current graph. HOLD ON holds the current plot and all axis properties so that subsequent graphing commands add to the existing graph. HOLD OFF returns to the default mode HOLD, by itself, toggles the hold state. Example ... hold on; y2 = x + 2; plot(x, y2, 'g+:');
  • 74. Subplot SUBPLOT Create axes in tiled positions. SUBPLOT(m,n,p), or SUBPLOT(mnp), breaks the Figure window into an m-by-n matrix of small axes Example x = [-3 -2 -1 0 1 2 3]; y1 = (x.^2) -1; % Plot y1 on the top subplot(2,1,1); plot(x, y1,'bo-.'); xlabel('x values'); ylabel('y values'); % Plot y2 on the bottom subplot(2,1,2); y2 = x + 2; plot(x, y2, 'g+:');
  • 75. Figure FIGURE Create figure window. FIGURE, by itself, creates a new figure window, and returns its handle. Example x = [-3 -2 -1 0 1 2 3]; y1 = (x.^2) -1; % Plot y1 in the 1st Figure plot(x, y1,'bo-.'); xlabel('x values'); ylabel('y values'); % Plot y2 in the 2nd Figure figure y2 = x + 2; plot(x, y2, 'g+:');
  • 76. Surface Plot x = 0:0.1:2; x = 0:0.1:2; y = 0:0.1:2; y = 0:0.1:2; [xx, yy] = meshgrid(x,y); [xx, yy] = meshgrid(x,y); zz=sin(xx.^2+yy.^2); zz=sin(xx.^2+yy.^2); surf(xx,yy,zz) surf(xx,yy,zz) xlabel('X axes') xlabel('X axes') ylabel('Y axes') ylabel('Y axes')
  • 77. 2D line plot 0.8 0.6 0.4 0.2 amplitude >> x=0:0.05:5; >> y=sin(x.^2); >> plot(x,y); >> xlabel('time'); >> plot(x,y); >> xlabel('time'); >>ylabel('amplitude'); 1 0 -0.2 -0.4 -0.6 -0.8 -1 0 0.5 1 1.5 2 2.5 time 3 3.5 4 4.5 5
  • 78. Bar plot >> x=-2.9:0.2:2.9; >> bar(x,exp(-x.*x)); >> 1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0 -3 -2 -1 0 1 2 3
  • 79. Stairstep plot of sine wave >> x=0:0.25:10; >> stairs(x,sin(x)); 1 0.8 0.6 0.4 0.2 0 -0.2 -0.4 -0.6 -0.8 -1 0 1 2 3 4 5 6 7 8 9 10
  • 80. M-Files Script file: a collection of MATLAB commands Function file: a definition file for one function
  • 81. Script Files Any valid sequence of MATLAB commands can be in the script files. Variables defined/used in script files are global, i.e., they present in the workspace.
  • 82.
  • 83.
  • 84.
  • 85. Using Script M-files » what M-files in the current directory C:WINDOWSDesktopMatlab-Tutorials abc abc1 » abc 1 3 5 . . . File Name
  • 86. M-file Example %test.m for i=1:5 for j=1:i fprintf('*'); end fprintf('n'); end %output >> test * ** *** **** *****
  • 87. Writing User Defined Functions Functions are m-files which can be executed by specifying some inputs and supply some desired outputs. The code telling the Matlab that an m-file is actually a function is function out1=functionname(in1) function out1=functionname(in1,in2,in3) function [out1,out2]=functionname(in1,in2) You should write this command at the beginning of the m-file and you should save the m-file with a file name same as the function name
  • 88. Writing User Defined Functions Examples Write a function : out=squarer (A, ind) Which takes the square of the input matrix if the input indicator is equal to 1 And takes the element by element square of the input matrix if the input indicator is equal to 2 Same Name
  • 89. Writing User Defined Functions Another function which takes an input array and returns the sum and product of its elements as outputs The function sumprod(.) can be called from command window or an m-file as
  • 90. Function Example1 multiply.m function y = multiply(a,b) y=a*b; end output >> multiply(23,3) ans = 69
  • 91. Function Example2 function1.m function [out1,out2] = function1(a,b) out1=sin(a); out2=sin(b); end output [a,b]=function1(2,4) a= 0.9093 b= -0.7568
  • 92. Cluster Analysis? Finding groups of objects such that the objects in a group will be similar (or related) to one another and different from (or unrelated to) the objects in other groups
  • 94. Hierarchical clustering Algorithm Description 1. Determine the distance between each pair of points 2. Iteratively group points into a binary hierarchical cluster tree(linkage) 3. cut the hierarchical tree into cluster
  • 95. Hierarchical clustering 1. 0.075 0.07 0.065 2. 0.06 0.055 0.05 2 28 7 24 27 21 18 12 6 9 15 26 10 3 8 29 5 17 22 13 30 16 1 23 4 11 20 19 25 14 3.
  • 96. Hierarchical clustering using matlab load fisheriris X=meas Y = pdist(X) z=linkage(Y) dendrogram(z) 0.075 0.07 0.065 0.06 0.055 0.05 2 28 7 24 27 21 18 12 6 9 15 26 10 3 8 29 5 17 22 13 30 16 1 23 4 11 20 19 25 14
  • 97. Hierarchical clustering using matlab 7 load fisheriris X=meas Y = pdist(X) z=linkage(Y) dendrogram(z) hidx=cluster(z,'MaxClust',3) ptsymb = {'bs','r^','md','go','c+'}; for i=1:max(hidx) clust=find(hidx==i) plot3(X(clust,1),X(clust,2),X(clust,3),ptsymb{i}); hold on; end 6 5 4 3 2 1 4.5 4 3.5 3 2.5 2 4 4.5 5 5.5 6 6.5 7 7.5 8

Notas do Editor

  1. Instructor notes: A matrix with a single row is called a row vector. Row vectors in Matlab can be created by assigning a variable to a list of individual elements. The elements must be contained within square brackets and can be separated by commas or spaces or both. Matlab is not overly picky about the separators between elements of a given row vector or row within a matrix. To reemphasize the semicolon as output suppression operator, you might want to point out that putting a semicolon at the end of the line assigning elements to rowvec would have prevented its contents from being displayed.