Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 19

INTRODUCTION

The tutorials are independent of the rest of the document. The primarily objective is to help you learn
quickly the ¯rst steps. The emphasis here is \learning by doing". Therefore, the best way to learn is by
trying it yourself. Working through the examples will give you a feel for the way that MATLAB operates.
In this introduction we will describe how MATLAB handles simple numerical expressions and
mathematical formulas.
The name MATLAB stands for MATrix LABoratory. MATLAB was written originally to provide easy access
to matrix software developed by the LINPACK (linear system package) and EISPACK (Eigen system
package) projects.
MATLAB [1] is a high-performance language for technical computing. It integrates computation,
visualization, and programming environment. Furthermore, MATLAB is a modern programming
language environment: it has sophisticated data structures, contains built-in editing and debugging
tools, and supports object-oriented programming. These factors make MATLAB an excellent tool for
teaching and research.
MATLAB has many advantages compared to conventional computer languages (e.g., C, FORTRAN) for
solving technical problems. MATLAB is an interactive system whose basic data element is an array that
does not require dimensioning. The software package has been commercially available since 1984 and is
now considered as a standard tool at most universities and industries worldwide.
It has powerful built-in routines that enable a very wide variety of computations. It also has easy to use
graphics commands that make the visualization of results immediately available. Speci¯c applications are
collected in packages referred to as toolbox. There are toolboxes for signal processing, symbolic
computation, control theory, simulation, optimization, and several other ¯elds of applied science and
engineering.
In addition to the MATLAB documentation which is mostly available on-line, we would
1 recommend the following books: [2], [3], [4], [5], [6], [7], [8], and [9]. They are excellent in their
speci¯c applications.

HISTORY

Release
Version[17] Year Notes
name
MATLAB 1.0 1984
MATLAB 2 1986
MATLAB 3 1987
Ran on MS-DOS but required at least a 386 processor. Version
MATLAB 3.5 1990
3.5m required math coprocessor
MATLAB 4 1992
MATLAB
R7 1994 Ran on Windows 3.1. Required a math coprocessor
4.2c
MATLAB 5.0 R8 1996
MATLAB 5.1 R9
MATLAB 1997
R9.1
5.1.1

ANKUR JAIN MATLAB 0361563608


MATLAB 5.2 R10
MATLAB 1998
R10.1
5.2.1
MATLAB 5.3 R11
MATLAB 1999
R11.1
5.3.1
MATLAB 6.0 R12 2000
MATLAB 6.1 R12.1 2001
MATLAB 6.5 R13 2002
MATLAB
R13SP1 2003
6.5.1
MATLAB
R13SP1 2003
6.5.1
MATLAB
R13SP2
6.5.2
MATLAB 7 R14 2004
MATLAB
R14SP1
7.0.1
MATLAB
R14SP2 2005
7.0.4
MATLAB 7.1 R14SP3
MATLAB 7.2 R2006a 2006
MATLAB 7.3 R2006b
MATLAB 7.4 R2007a 2007
MATLAB 7.5 R2007b Last release for Windows 2000 and PowerPC Mac.
MATLAB 7.6 R2008a 2008
MATLAB 7.7 R2008b
MATLAB 7.8 R2009a 2009 First release for 32-bit & 64-bit Windows 7.
MATLAB 7.9 R2009b First release for Intel 64-bit Mac, and last for Solaris SPARC.
MATLAB
R2010a 2010 Last release for Intel 32-bit Mac.
7.10
MATLAB
R2010b
7.11

ANKUR JAIN MATLAB 0361563608


EXPERIMENT NO:-01

AIM:- TO STUDY AND GENERATE BASIC SIGNALS.

SOFTWARE USED: MATLAB

CODE:-

1. FOR COS SIGNAL

t=0:.01:pi;

y=cos(2*pi*t);

subplot(2,1,2);

plot(t,y);

ylabel('Amplitude');

xlabel('(b)n-->');

WAVEFORM OUTPUT
a m p lit u d e -->

0.5

-0.5

-1
0 0.5 1 1.5 2 2.5 3 3.5
(b)n-->

2. FOR SIN SIGNAL

t=0:.01:pi;

y=sin(2*pi*t);

subplot(2,1,2);

plot(t,y);

ylabel('Amplitude-->');

xlabel('(a)n-->');

ANKUR JAIN MATLAB 0361563608


WAVEFORM OUTPUT

A m p lit u d e -->
1

0.5

-0.5

-1
0 0.5 1 1.5 2 2.5 3 3.5
(a)n-->

3. FOR RAMP SIGNAL

n=input(‘enter the N values=’);

enter the N values=6

t=0:n;

subplot(2,2,3);

stem(t,t);

ylabel('Amplitude-->');

xlabel('(c)n-->');

WAVEFORM OUTPUT

6
Amplitude-->

0
0 2 4 6
(c)n-->

ANKUR JAIN MATLAB 0361563608


4.FOR UNIT STEP SIGNAL

n=input(‘enter the N values=’);

enter the N values=4

t=0:1:n-1;

y1=ones(1,n);

subplot(2,2,2);

stem(t,y1);

ylabel('Amplitude-->');

xlabel('(d)n-->');

WAVEFORM OUTPUT

1
Amplitude-->

0.5

0
0 1 2 3
(d)n==>

RESULT:- THE BASIC SIGNALS HAVE BEEN VERIFIED.

ANKUR JAIN MATLAB 0361563608


EXPERIMENT NO. 02

AIM:- TO STUDY AND GENERATE COMPLEX EXPONENTIAL SEQUENCE.

SOFTWARE USED:- MATLAB

CODE:-

a=input(‘Type in real complex exponential sequence=’);

Type in real complex exponential sequence=4

b=input(‘Type in imaginary exponential sequence=’);

Type in imaginary exponential sequence=10

C=a+b*I;

K=input(‘Type in the gain constant=’);

Type in the gain constant=5

a=input(‘Type in the length of the sequence=’);

Type in the length of the sequence=8

N=1:N;

X=K*exp(c*n);

Stem(n,real(x));

Xlabel(‘Time index n’);

Ylabel(‘Amplitude’);

title(‘Real part’);

disp(‘press return for imginary part’);

pause

stem(n,imag(x));

xlabel(‘Time index n’);

ylabel(‘Amplitude’);

title(‘imaginary part’)

ANKUR JAIN MATLAB 0361563608


WAVEFORM OUTPUT

13
x 10 Real Part
0.5

-0.5

-1

-1.5
amplitude

-2

-2.5

-3

-3.5

-4

-4.5
1 2 3 4 5 6 7 8
Time index n

14
x 10 imaginary part
0.5

-0.5

-1
amplitude

-1.5

-2

-2.5

-3

-3.5

-4
1 2 3 4 5 6 7 8
Time index n

RESULT:- COMPLEX EXPONENTIAL SEQUENCE HAS BEEN VERIFIED.

ANKUR JAIN MATLAB 0361563608


EXPERIMENT NO:-03

AIM:- TO STUDY AND GENERATE REAL EXPONENTIAL SEQUENCE.

SOFTWARE USED:- MATLAB

CODE:-

a=input(‘Type in argument=’);

Type in argument=3

K=input(‘Type in the gain constant=’);

Type in the gain constant=1

N=input(‘Type in the lengthof sequence=’);

Type in the lengthof sequence=2

n=0:N;

Stem(n,real(x));

Xlabel(‘Time index n’);

Ylabel(‘Amplitude’);

WAVEFORM OUTPUT

5
Amplitude

0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Type index n

RESULT:- REAL EXPONENTIAL CODE HAS BEEN VERIFIED.

ANKUR JAIN MATLAB 0361563608


EXPERIMENT NO:- 04

AIM:- TO STUDY THE ILLUSTRATION OF CONVOLUTION.

SOFTWARE USED:- MATLAB

CODE:-

a=input(‘Type in first sequence=’);

Type in first sequence=2

b=input(‘Type in second sequence=’);

Type in second sequence=4

C=conv(a,b);

M=length(c)-1;

n=0:1:M;

disp(‘output sequence=’);

disp(c);

stem(n,c);

xlabel(‘Time index n’);

ylabel(‘Amplitude’);

WAVEFORM OUTPUT :

5
Amplitude

0
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
Time index n

RESULT:- CONVOLUTION HAS BEEN SUCCESSFULLY ILLUSTRATED.

ANKUR JAIN MATLAB 0361563608


EXPERIMENT NO:- 05

AIM:- TO STUDY AND COMPUTE THE CROSS CORRELATION SEQUENCE.

SOFTWARE USED:- MATLAB

CODE:-

%computation of cross correlation

X=input(‘Type in the reference sequence=’);

Type in the reference sequence=3

y=input(‘Type in the second sequence=’);

Type in the second sequence=20

%computation of correlation sequence

n1=length(y)-1;

n2=length(x)-1;

r=conv(x,fliplr(y);

%fliplr:-Fliplr:-Flip matrices left-right [syntax B=fliplr(A)]

K=(-n1):n2;

Stem(k,r);

Xlabel(‘lag index’);

Ylabel(‘amplitude’);

ANKUR JAIN MATLAB 0361563608


WAVEFORM OUTPUT

60

50

40
amplitude

30

20

10

0
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
lag index

RESULT:- CROSS CORRELATION SEQUENCE HAS BEEN VERIFIED.

ANKUR JAIN MATLAB 0361563608


EXPERIMENT NO:- 06

AIM:- TO STUDY AND COMPUTE THE AUTO CORRELATION SEQUENCE.

SOFTWARE USED:- MATLAB

CODE:-

N=96;

N=1:N;

x=cos(pi*0.25*n);

y=x+d;

r=conv(y,fliplr(y));

K=-28:28;

Stem(K,r(68:124));

Xlabel(‘lag index’);

Ylabel(‘Amplitude’);

WAVEFORM OUTPUT

60

40

20
Amplitude

-20

-40

-60
-30 -20 -10 0 10 20 30
Lag index

RESULT:- THE AUTO CORRELATION SEQUENCE HAS BEEN VERIFIED.

ANKUR JAIN MATLAB 0361563608


EXPERIMENT NO:- 07

AIM:-ILLUSTRATION OF IDFT COMPUTATION.

SOFTWARE USED:- MATLAB

CODE:-

K=input(‘Type in the length of the DFT=’);

Type in the length of the DFT=4

N=input(‘Type in the length of the IDFT=’);

Type in the length of the IDFT=7

k=0:K-1;

V=k/K;

V=ifft(V,N);

Stem(k,V);

title(‘original DFT sample’);

xlabel(‘Time index n’);

ylabel(‘Amplitude’);

pause

subplot(2,1,1);

n=0:N-1;

stem(n,real(v));

title(‘real part of the time-domain samples’);

xlabel(‘time index n’);

ylabel(‘Amplitude’);

subplot(2,1,2);

stem(n,imag(v));

title(‘imaginary part of the domain samples’);

ANKUR JAIN MATLAB 0361563608


xlabel(‘Time index n’);

ylabel(‘Amplitude’);

WAVEFORM OUTPUT

original DFT sample


0.8

0.7

0.6

0.5
Amplitude

0.4

0.3

0.2

0.1

0
0 0.5 1 1.5 2 2.5 3
Time index n

real part of the time-domain samples


0.3

0.2
Amplitude

0.1

-0.1
0 1 2 3 4 5 6
time index n
imaginary part of the time domain samples
0.2

0.1
Amplitude

-0.1

-0.2
0 1 2 3 4 5 6
Time index n

RESULT:- IDFT HAS BEEN COMPUTED.

ANKUR JAIN MATLAB 0361563608


EXPERIMENT NO:- 08

AIM:- TO FIND THE MAGNITUDE AND PHASE ANGLE OF A SEQUENCE.

SOFTWARE USED:- MATLAB

CODE:-

a=[1 -0.9 0.81];

b=[1 1];

w=(0:500)*(pi/500);

x=freqz(b,a,w);

mag=abs(x);

phase=angle(x)*180/pi;

subplot(2,1,1);

plot(mag);

gtext(‘magnitude’);

subplot(2.1.1);

plot(phase);

gtext(‘phase angle’);

WAVEFORM OUTPUT

15

10

0
0 100 200 300 400 500 600
magnitude

50

-50

-100

-150
0 100 200 300 400 500 600
phase angle

RESULT:- MAGNITUDE AND PHASE ANGLE HAVE BEEN DETERMINED.

ANKUR JAIN MATLAB 0361563608


EXPERIMENT NO:- 09
AIM:- TO FIND THE DFT OF A GIVEN SEQUENCE.

SOFTWARE USED:- MATLAB

CODE:-

N=input(‘Type in the length of sequence=’);

Type in the length of sequence=4

M=input(‘Type in the length of DFT=’);

Type in the length of DFT=7

u=[ones(1,N)];

U=fft(u,M);

t=0:1:N-1;

stem(t,u);

title(original time domain sequence’);

xlabel(‘Time index n’);

ylabel(‘Amplitude’);

pause

subplot(2,1,1);

k=0:1:M-1;

stem(k,abs(U));

title(‘mag of the DFT samples’);

xlabel(‘Frequency index k);

ylabel(‘Magnitude’);

subplot(2,1,2);

stem(k.angle(U));

title(‘phase of the DFT samples’);

ANKUR JAIN MATLAB 0361563608


xlabel(‘Frequency index k’);

ylabel(‘phase’);

WAVEFORM OUTPUT

original time domain sequence


1

0.9

0.8

0.7

0.6
Amplitude

0.5

0.4

0.3

0.2

0.1

0
0 0.5 1 1.5 2 2.5 3
Time index n

mag of the DFT samples


4

3
Magnitude

0
0 1 2 3 4 5 6
Frequency index k
phase of the DFT samples
2

1
phase

-1

-2
0 1 2 3 4 5 6
Frequency index k

RESULT:- THE DFT OF THE GIVEN SEQUENCE HAS BEEN DETERMINED.

ANKUR JAIN MATLAB 0361563608


INDEX
S.NO TOPIC DATE SIGNATURE
TO STUDY AND GENERATE BASIC
1 SIGNALS.

TO STUDY AND GENERATE COMPLEX


EXPONENTIAL SEQUENCE.
2
TO STUDY AND GENERATE REAL
3 EXPONENTIAL SEQUENCE.

TO STUDY THE ILLUSTRATION OF


4 CONVOLUTION.

STUDY AND COMPUTE THE CROSS


5 CORRELATION SEQUENCE.

TO STUDY AND COMPUTE THE AUTO


6 CORRELATION SEQUENCE.

ILLUSTRATION OF IDFT
7 COMPUTATION.

8 TO FIND THE MAGNITUDE AND PHASE


ANGLE OF A SEQUENCE.

9 TO FIND THE DFT OF A GIVEN


SEQUENCE.

ANKUR JAIN MATLAB 0361563608


MATLAB
PRACTICAL FILE

SUBMITTED BY:
NAME: ANKUR JAIN
BRANCH: MAE IIIRD YEAR
ROLL NO: 0361563608

ANKUR JAIN MATLAB 0361563608

You might also like