Release Name Year Notes
Release Name Year Notes
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
CODE:-
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-->
t=0:.01:pi;
y=sin(2*pi*t);
subplot(2,1,2);
plot(t,y);
ylabel('Amplitude-->');
xlabel('(a)n-->');
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-->
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-->
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==>
CODE:-
C=a+b*I;
N=1:N;
X=K*exp(c*n);
Stem(n,real(x));
Ylabel(‘Amplitude’);
title(‘Real part’);
pause
stem(n,imag(x));
ylabel(‘Amplitude’);
title(‘imaginary part’)
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
CODE:-
a=input(‘Type in argument=’);
Type in argument=3
n=0:N;
Stem(n,real(x));
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
CODE:-
C=conv(a,b);
M=length(c)-1;
n=0:1:M;
disp(‘output sequence=’);
disp(c);
stem(n,c);
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
CODE:-
n1=length(y)-1;
n2=length(x)-1;
r=conv(x,fliplr(y);
K=(-n1):n2;
Stem(k,r);
Xlabel(‘lag index’);
Ylabel(‘amplitude’);
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
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
CODE:-
k=0:K-1;
V=k/K;
V=ifft(V,N);
Stem(k,V);
ylabel(‘Amplitude’);
pause
subplot(2,1,1);
n=0:N-1;
stem(n,real(v));
ylabel(‘Amplitude’);
subplot(2,1,2);
stem(n,imag(v));
ylabel(‘Amplitude’);
WAVEFORM OUTPUT
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
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
CODE:-
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
CODE:-
u=[ones(1,N)];
U=fft(u,M);
t=0:1:N-1;
stem(t,u);
ylabel(‘Amplitude’);
pause
subplot(2,1,1);
k=0:1:M-1;
stem(k,abs(U));
ylabel(‘Magnitude’);
subplot(2,1,2);
stem(k.angle(U));
ylabel(‘phase’);
WAVEFORM OUTPUT
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
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
ILLUSTRATION OF IDFT
7 COMPUTATION.
SUBMITTED BY:
NAME: ANKUR JAIN
BRANCH: MAE IIIRD YEAR
ROLL NO: 0361563608