Output Matlab
-
Upload
ankur-jain -
Category
Documents
-
view
216 -
download
0
Transcript of Output Matlab
-
8/3/2019 Output Matlab
1/20
ANKUR JAIN MATLAB 0361563608
INTRODUCTION
The tutorials are independent of the rest of the document. The primarily objective is to help you learn
quicklythe 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 andmathematical 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, andprogramming 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 arraythatdoes 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
nameYear Notes
MATLAB1.0
1984
MATLAB 2 1986
MATLAB 3 1987
MATLAB
3.5 1990Ran on MS-DOS but required at least a 386 processor. Version
3.5m required math coprocessor
MATLAB 4 1992
MATLAB
4.2cR7 1994 Ran on Windows 3.1. Required a math coprocessor
MATLAB
5.0R8 1996
http://en.wikipedia.org/wiki/MATLAB#cite_note-growth-16http://en.wikipedia.org/wiki/MATLAB#cite_note-growth-16http://en.wikipedia.org/wiki/MATLAB#cite_note-growth-16 -
8/3/2019 Output Matlab
2/20
ANKUR JAIN MATLAB 0361563608
MATLAB5.1
R9
1997MATLAB
5.1.1R9.1
MATLAB
5.2 R101998
MATLAB
5.2.1R10.1
MATLAB5.3
R11
1999MATLAB
5.3.1R11.1
MATLAB
6.0R12 2000
MATLAB
6.1 R12.1 2001
MATLAB
6.5R13 2002
MATLAB
6.5.1R13SP1 2003
MATLAB
6.5.1R13SP1 2003
MATLAB
6.5.2R13SP2
MATLAB 7 R14 2004
MATLAB7.0.1
R14SP1
MATLAB
7.0.4R14SP2 2005
MATLAB7.1
R14SP3
MATLAB
7.2R2006a 2006
MATLAB
7.3R2006b
MATLAB
7.4R2007a 2007
MATLAB
7.5R2007b Last release for Windows 2000 and PowerPC Mac.
MATLAB
7.6R2008a 2008
MATLAB R2008b
-
8/3/2019 Output Matlab
3/20
ANKUR JAIN MATLAB 0361563608
7.7
MATLAB
7.8R2009a 2009 First release for 32-bit & 64-bit Windows 7.
MATLAB
7.9R2009b First release for Intel 64-bit Mac, and last for Solaris SPARC.
MATLAB
7.10R2010a 2010 Last release for Intel 32-bit Mac.
MATLAB
7.11R2010b
-
8/3/2019 Output Matlab
4/20
ANKUR JAIN MATLAB 0361563608
EXPERIMENT NO:-01
AIM:- TO STUDY AND GENERATE BASIC SIGNALS.
SOFTWARE USED: MATLAB
CODE:-
1. FOR COS SIGNALt=0:.01:pi;
y=cos(2*pi*t);
subplot(2,1,2);
plot(t,y);
ylabel('Amplitude');
xlabel('(b)n-->');
WAVEFORM OUTPUT
2. FOR SIN SIGNALt=0:.01:pi;
y=sin(2*pi*t);
subplot(2,1,2);
plot(t,y);
ylabel('Amplitude-->');
xlabel('(a)n-->');
0 0.5 1 1.5 2 2.5 3 3.5-1
-0.5
0
0.5
1
a
mplitude-->
(b)n-->
-
8/3/2019 Output Matlab
5/20
ANKUR JAIN MATLAB 0361563608
WAVEFORM OUTPUT
3. FOR RAMP SIGNALn=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
0 0.5 1 1.5 2 2.5 3 3.5-1
-0.5
0
0.5
1
Amplitude-->
(a)n-->
0 2 4 60
2
4
6
Amplitude-->
(c)n-->
-
8/3/2019 Output Matlab
6/20
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
RESULT:- THE BASIC SIGNALS HAVE BEEN VERIFIED.
0 1 2 30
0.5
1
Amplitude-->
(d)n==>
-
8/3/2019 Output Matlab
7/20
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)
-
8/3/2019 Output Matlab
8/20
ANKUR JAIN MATLAB 0361563608
WAVEFORM OUTPUT
RESULT:- COMPLEX EXPONENTIAL SEQUENCE HAS BEEN VERIFIED.
1 2 3 4 5 6 7 8-4.5
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
0.5x 10
13
Time index n
amplitude
Real Part
1 2 3 4 5 6 7 8
-4
-3.5
-3
-2.5
-2
-1.5
-1
-0.5
0
0.5x 10
14
Time index n
amplitude
imaginary part
-
8/3/2019 Output Matlab
9/20
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
RESULT:- REAL EXPONENTIAL CODE HAS BEEN VERIFIED.
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 20
1
2
3
4
5
6
7
8
9
Type index n
Amplitude
-
8/3/2019 Output Matlab
10/20
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 :
RESULT:- CONVOLUTION HAS BEEN SUCCESSFULLY ILLUSTRATED.
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 10
1
2
3
4
5
6
7
8
Time index n
Amplitude
-
8/3/2019 Output Matlab
11/20
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);
-
8/3/2019 Output Matlab
12/20
ANKUR JAIN MATLAB 0361563608
WAVEFORM OUTPUT
RESULT:- CROSS CORRELATION SEQUENCE HAS BEEN VERIFIED.
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 10
10
20
30
40
50
60
lag index
amplitude
-
8/3/2019 Output Matlab
13/20
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
RESULT:- THE AUTO CORRELATION SEQUENCE HAS BEEN VERIFIED.
-30 -20 -10 0 10 20 30-60
-40
-20
0
20
40
60
Lag index
Amplitude
-
8/3/2019 Output Matlab
14/20
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);
-
8/3/2019 Output Matlab
15/20
ANKUR JAIN MATLAB 0361563608
xlabel(Time index n);
ylabel(Amplitude);
WAVEFORM OUTPUT
RESULT:- IDFT HAS BEEN COMPUTED.
0 0.5 1 1.5 2 2.5 30
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8original DFT sample
Time index n
Amplitude
0 1 2 3 4 5 6-0.1
0
0.1
0.2
0.3real part of the time-domain samples
time index n
Amplitud
e
0 1 2 3 4 5 6-0.2
-0.1
0
0.1
0.2imaginary part of the time domain samples
Time index n
Am
plitude
-
8/3/2019 Output Matlab
16/20
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
RESULT:- MAGNITUDE AND PHASE ANGLE HAVE BEEN DETERMINED.
0 100 200 300 400 500 6000
5
10
15
magnitude
0 100 200 300 400 500 600-150
-100
-50
0
50
phase angle
-
8/3/2019 Output Matlab
17/20
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);
-
8/3/2019 Output Matlab
18/20
ANKUR JAIN MATLAB 0361563608
xlabel(Frequency index k);
ylabel(phase);
WAVEFORM OUTPUT
RESULT:- THE DFT OF THE GIVEN SEQUENCE HAS BEEN DETERMINED.
0 0.5 1 1.5 2 2.5 30
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1original t ime domain sequence
Time index n
Amplitude
0 1 2 3 4 5 60
1
2
3
4mag of the DFT samples
Frequency index k
Magnitude
0 1 2 3 4 5 6-2
-1
0
1
2phase of the DFT samples
Frequency index k
phase
-
8/3/2019 Output Matlab
19/20
ANKUR JAIN MATLAB 0361563608
INDEX
S.NO TOPIC DATE SIGNATURE
1TO STUDY AND GENERATE BASICSIGNALS.
2
TO STUDY AND GENERATE COMPLEX
EXPONENTIAL SEQUENCE.
3
TO STUDY AND GENERATE REAL
EXPONENTIAL SEQUENCE.
4
TO STUDY THE ILLUSTRATION OF
CONVOLUTION.
5
STUDY AND COMPUTE THE CROSS
CORRELATION SEQUENCE.
6
TO STUDY AND COMPUTE THE AUTO
CORRELATION SEQUENCE.
7
ILLUSTRATION OF IDFT
COMPUTATION.
8 TO FIND THE MAGNITUDE AND PHASEANGLE OF A SEQUENCE.
9 TO FIND THE DFT OF A GIVENSEQUENCE.
-
8/3/2019 Output Matlab
20/20
MATLAB
PRACTICAL FILE
SUBMITTED BY:
NAME: ANKUR JAIN
BRANCH: MAE IIIRD YEAR
ROLL NO: 0361563608