0% found this document useful (0 votes)
29 views3 pages

Familiarization of Matlab - Part2 - lsdcRNyfAH

Uploaded by

monishdas988
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views3 pages

Familiarization of Matlab - Part2 - lsdcRNyfAH

Uploaded by

monishdas988
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Pr epar ed by M r .

Ankur Jyoti Sar mah


Assistant Pr ofessor
Depar tment of Electr onics & Telecommunication
Assam Engineer ing College
Systems Lab

DATE: 08-02-2011

EXPERIMENT NO.1

FAMILIARISATION OF MATLAB

AIM
To familiarize with MATLAB and its functions.
THEORY
MATLAB is an ideal software tool for studying digital signal processing. The plotting capacity
of MATLAB makes it possible to view the result of processing and gain understanding into
complicated operations. The tool box support a wide range of signal processing from waveform
generation to filter design and implementation, parametric modelling and spectral analysis. There are
two categories of tools Signal processing functions Graphical interaction tools. The first category of
tools is made of functions that we can call from the common line or from your own application. Many
of the functions are MATLAB statements that implement specialized signal processing algorithm.

(a) DEFINTION OF VARIABLES


Variables are assigned numerical values by typing the expression directly
Eg: a=1+2 yields a=3
The answer will not be displayed when semicolon is put at the end of an expression
Eg: a=1+2

MATLAB utilizes the following arithmetic operations


+ Addition
- Subtraction
* Multiplication
/ Division
ˆpower operation
„Transpose
A variable can be assigned using a formula that utilizes these operations and either numbers or
previously defined variables.
Eg: since „a‟ was defined previously the following expression is valid, B=z*a.To determine the value
of a previously defined quantity type the quantity by b=6. If your expression does not fill on the line,
use an ellipse and continue on the next line.
C=1+2+3+. . . . . . . . . . . . ..+5+6+7. These are certain predefined variables which can be used at any
time, in the same manner as user defined variables.
i=sqrt(-1); j=sqrt(-1)

Dept. Of ECE, SJCET, Palai 1


Systems Lab

pi=3.1416
Eg: y=2*(1+4*j)yields y=2.000+8.000y
These are also a number of predefined functions that can be used when defining a variable.
Some common functions that are used in this text are Abs- magnitude of a number Angle- angle of a
complex numberCos- cosine function, assume arguments in radian.
Exp-exponential functions
For example with y defined as aboveE= abs(y), yields e=8.2462, c=angle(y) yields c=1.3258
with a=3 as defined previously c=cos(a)yields, c= -0.9900c = exp(a), yields c=20.0855.Note that exp
can be used on complex numbers example with y = 2 + 8i as defined above
c = -1.0751 + 7.3104i which can be verified by using Euler‟s formula
c = c2cos(8) + jc2sin(8).

(b) DEFINTION OF MATRICES

MATLAB is based on matrix and vector algebra. Even scalars are treated 1x1 matrix.
Therefore, vector and matrix operation are simple as common calculator operations. Vectors can be
defined in two ways. The first method is used for arbitrary elements, v=[1 3 5 7] creates 1x4 vector
elements with elements 1 3 5 &7. Note that commas would have been used in the place of spaces to
separate the elements. Additional elements can be added to the vector v(5)=8 yields the vector v =
[1357]. Previously defined vectors can be used to define a new vectors. For example with we defined
above a= [910]; b = [v a]; creates the vector b = [1357910]. The second method is used for creating
vector with equally spaced elements t=0:0.1:10; creates 1x101 vector with elements0,0.1,0.2. . . . . 10.
Note that the middle number defines the increments is set to a default of 1k=0,10 creates 1x11 vector
with the elements 0,1,2. . . .10. Matrices are defined by entering the element row by row. M = [124;
368] creates the matrix M= 1 2 43 6 8 There are number of special matrices that can be defined Null
matrix: [ ];
Nxm matrixes of zero: M=zeros (m,m);
Nxm matrix of ones: M= ones (n,m);
Nxn matrix of identity: M=eye (n)
A particular elements of matrix can e assigned M(1,2)=5 place the number 5 in the first
row,2nd column. Operations and functions that were defined for scalars in the previous section can be
used on vectors and matrices. For example a=[1 2 3]; b=[4 5 6]; c=a+b yield c=579. Functions are
applied element by element. For example t=0:„0; x=cos(2*t) creates a vector „x‟ with elements equal
to cos(2t) for t=0,1,2. . . ..10
(c) GENERAL INFORMATION
MATLAB is case sensitive. So „a‟ and „A‟ are two different names. Comment statements are
preceded by a %.

Dept. Of ECE, SJCET, Palai 2


Systems Lab

1) M-files M-files are macros of MATLAB commands that are stored as ordinary text file
with the extension „in‟ that is „filename.m‟. An m-file can be either a function with input and output
variables or a set of commands. MATLAB requires that the m-file must be stored either in the
working directory or in a directory that is specified in the MATLAB path list. The following
commands typed from within MATLAB demonstrate how this m-file is used. X=2,y=3,z=y plusx(y,x)
MATLAB m-files are most efficient when written in a way that utilizes matrix or vector operations,
loops and if statements are available, but should be used sparingly since they are computationally
inefficient. An examples is For k=1:10 x(k)=cos(k) end; This creates a 1x10vector „x‟ containing the
cosine of the positive integers from 1 to 10. This operation is performed more efficiently with the
commands k=1:10 x=cos(k) which utilizes a function of a vector instead of a for loop. An if statement
can be used to define combinational statement.

(d) REPRESENTATION OF SIGNALS


A signal can be defined as function that conveys information, generally about or behaviour of
physical system; signals are represented mathematically as functions of one or more independent
variables. The independent variables is the mathematical expression of a signal may be either
continuous is discrete. Continuous time signals are defined along a number of times and thus they
are represented by a continuous independent variable. TheMATLAB is case sensitive. Discrete time
signals are represented mathematically.Continuoustimesignals are often referred to as analog
signals. Discrete time signals are defined at discrete times and thus the independent variable has
discrete values. In a sequence of numbers x, the nthnumber in the sequence is denoted as x[n]. The
basic signals used in digital signal processing are the unit impulse signal [U+0260](n), exponential of
the form au[n], sine waves and their generalization to complex exponentials. Since the only numerical
data type in MATLAB is the m x nmatrix, signals must be represented as vectors either mx1 matrix if
column vector 1xn matrices if row vectors. A constant will be treated as 1x1 matrix. The signals are
sampling frequency Fs,which is greater than twice the maximum frequency of the signal. In time
domain, the signals are represented as time versus amplitude. In MATLAB you can generate time
base for given signals T=t start: 1/Fs:t-stop,tstart is the starting time of the signal t-sto is the stop time
of the signal and Fs sampling frequency. 1/Fs is the time period between the two samples. In signals
like speech if the data secured length is too long, plotting of the whole signal will not be clean view.
In that case we can use step function.

RESULT

The familiarization of MATLAB was completed.

Dept. Of ECE, SJCET, Palai 3

You might also like