You are on page 1of 20

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. Specic 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 specic applications.

HISTORY
Version[17] Release name Year 1984 1986 1987 1990 1992 1994 Ran on Windows 3.1. Required a math coprocessor 1996 Ran on MS-DOS but required at least a 386 processor. Version 3.5m required math coprocessor Notes

MATLAB 1.0 MATLAB 2 MATLAB 3 MATLAB 3.5 MATLAB 4 MATLAB R7 4.2c MATLAB R8 5.0

ANKUR JAIN

MATLAB

0361563608

MATLAB 5.1 MATLAB 5.1.1 MATLAB 5.2 MATLAB 5.2.1 MATLAB 5.3 MATLAB 5.3.1 MATLAB 6.0 MATLAB 6.1 MATLAB 6.5 MATLAB 6.5.1 MATLAB 6.5.1 MATLAB 6.5.2 MATLAB 7 MATLAB 7.0.1 MATLAB 7.0.4 MATLAB 7.1 MATLAB 7.2 MATLAB 7.3 MATLAB 7.4 MATLAB 7.5 MATLAB 7.6 MATLAB
ANKUR JAIN

R9 1997 R9.1 R10 1998 R10.1 R11 1999 R11.1 R12 R12.1 R13 R13SP1 R13SP1 R13SP2 R14 R14SP1 R14SP2 R14SP3 R2006a R2006b R2007a R2007b R2008a R2008b
MATLAB 0361563608

2000 2001 2002 2003 2003

2004

2005

2006

2007
Last release for Windows 2000 and PowerPC Mac.

2008

7.7 MATLAB 7.8 MATLAB 7.9 MATLAB 7.10 MATLAB 7.11

R2009a R2009b R2010a R2010b

2009 First release for 32-bit & 64-bit Windows 7.


First release for Intel 64-bit Mac, and last for Solaris SPARC.

2010 Last release for Intel 32-bit Mac.

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
1
amplitude-->

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

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

1
Amplitude-->

0.5 0 -0.5 -1

0.5

1.5 (a)n-->

2.5

3.5

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

Amplitude-->

2 (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

1 (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
x 10
13

Real Part

0.5 0 -0.5 -1 -1.5


amplitude

-2 -2.5 -3 -3.5 -4 -4.5

4 5 Time index n
imaginary part

0.5 0 -0.5 -1
amplitude

x 10

14

-1.5 -2 -2.5 -3 -3.5 -4

4 5 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
9 8 7 6
Amplitude

5 4 3 2 1 0

0.2

0.4

0.6

0.8 1 1.2 Type index n

1.4

1.6

1.8

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 :
8 7 6 5
Amplitude

4 3 2 1 0 -1

-0.8

-0.6

-0.4

-0.2 0 0.2 Time index n

0.4

0.6

0.8

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 lag index

0.4

0.6

0.8

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 Lag index

10

20

30

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.5

1.5 Time index n

2.5

real part of the time-domain samples 0.3 0.2


Amplitude

0.1 0 -0.1

3 4 time index n imaginary part of the time domain samples

0.2 0.1
Amplitude

0 -0.1 -0.2

3 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

100

200

300 400 magnitude

500

600

50 0 -50 -100 -150

100

200

300 400 phase angle

500

600

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.5

1.5 Time index n

2.5

mag of the DFT samples 4 3 2 1 0

Magnitude

3 4 Frequency index k phase of the DFT samples

2 1
phase

0 -1 -2

3 Frequency index k

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

ANKUR JAIN

MATLAB

0361563608

INDEX
S.NO
1

TOPIC
TO STUDY AND GENERATE BASIC SIGNALS. TO STUDY AND GENERATE COMPLEX EXPONENTIAL SEQUENCE.

DATE

SIGNATURE

2 3 4 5 6 7 8 9
TO STUDY AND GENERATE REAL EXPONENTIAL SEQUENCE. TO STUDY THE ILLUSTRATION OF CONVOLUTION. STUDY AND COMPUTE THE CROSS CORRELATION SEQUENCE. TO STUDY AND COMPUTE THE AUTO CORRELATION SEQUENCE. ILLUSTRATION OF IDFT COMPUTATION. TO FIND THE MAGNITUDE AND PHASE ANGLE OF A SEQUENCE. 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