Sunteți pe pagina 1din 11

DATE

PAGE NO:
NAME OF THE EXPERIMENT:
MATLAB: MATLAB is a software package for high performance numerical computation and
Visualization provides an interactive environment with hundreds of built in functions for
Technical computation, graphics and animation. The MATLAB name stands for Matrix
Laboratory
At its core, MATLAB is essentially a set (a toolbox) of routines (called mfiles
or mex files) that sit on your computer and a window that allows you to create new variables
with names (e.g. voltage and time) and process those variables with any of those routines (e.g.
plot voltage against time, find the largest voltage, etc).
It also allows you to put a list of your processing requests together in a file and save that
combined list with a name so that you can run all of those commands in the same order at some
later time. Furthermore, it allows you to run such lists of commands such that you pass in data
and/or get data back out (i.e. the list of commands is like a function in most programming
languages). Once you save a function, it becomes part of your toolbox (i.e. it now looks to you
as if it were part of the basic toolbox that you started with).
For those with computer programming backgrounds: Note that MATLAB runs as an
interpretive language (like the old BASIC). That is, it does not need to be compiled. It simply
reads through each line of the function, executes it, and then goes on to the next line. (In
practice, a form of compilation occurs when you first run a function, so that it can run faster the
next time you run it.)
MATLAB works with through three basic windows:
MATLAB Windows:
Command Window: This is the main window .it is characterized by MATLAB command
Prompt >> when you launch the application program MATLAB puts you in this window all
Commands including those for user-written programs, are typed in this window at the MATLAB
Prompt
Graphics window: the output of all graphics commands typed in the command window are
Flushed to the graphics or figure window, a separate gray window with white background color
The user can create as many windows as the system memory will allow
Edit window: This is where you write edit, create and save your own programs in files called M
files.
Input-output:
MATLAB supports interactive computation taking the input from the screen and flushing, the
Output to the screen. In addition it can read input files and write output files
Data Type: the fundamental data type in MATLAB is the array. It encompasses several distinct
data objects- integers, real numbers, matrices, charcter strings, structures and cells.There is no
need to declare variables as real or complex, MATLAB automatically sets the variable to be real.
Dimensioning: Dimensioning is automatic in MATLAB. No dimension statements are required
for vectors or arrays .we can find the dimensions of an existing matrix or a vector with the size
and length commands.

J.B. Institute of Engineering and Technology

DATE
PAGE NO:
NAME OF THE EXPERIMENT:

Step function:
Program code:
clear all;
close all;
N=10;
t=1:1:10;
x=[ones(1,10)];
plot(t,x);

Figure:

Impulse function:
Program code:
clear all;
close all;
N=5;
t=-N:1:N;
x=[zeros(1,5) ones(1,1) zeros(1,5)];
stem(t,x);

Figure:

J.B. Institute of Engineering and Technology

DATE
PAGE NO:
NAME OF THE EXPERIMENT:

Ramp function:
Program code:
clear all;
close all;
a=2;
t=0:1:10;
x=a*t;
stem(t,x);

Figure:

J.B. Institute of Engineering and Technology

DATE
PAGE NO:
NAME OF THE EXPERIMENT:
Sine wave:

Program code:
clear all;
close all;
t=0:0.1:10;
x=sin(t);
plot(t,x);

Figure:

Cosine wave:

Program code:
clear all;
close all;
t=0:0.1:10;
x=cos(t);
plot(t,x);

Figure:

J.B. Institute of Engineering and Technology

DATE
PAGE NO:
NAME OF THE EXPERIMENT:

Summation and difference of two signals :


Program code:
clear all;
close all;
t=0:0.1:10;
x=sin(t);
subplot(2,2,1);
plot(t,x);
y=cos(t);
subplot(2,2,2);
plot(t,y);
z=x+y;
subplot(2,2,3);
plot(t,z);
xlabel('amplitude');
ylabel('time');
s=x-y;
subplot(2,2,4);
plot(s);
xlabel('time');
ylabel('amplitude');

Figure:

J.B. Institute of Engineering and Technology

DATE
PAGE NO:
NAME OF THE EXPERIMENT:

Exponential wave:
Program code:
clear all;
close all;
a=5;
t=0:0.1:10;
x=exp(a*t);
plot(t,x);

Figure:

J.B. Institute of Engineering and Technology

DATE
PAGE NO:
NAME OF THE EXPERIMENT:

Triangular wave:

Program code:
clear all;
close all;
t=0:0.1:10;
x=sawtooth(t,0.6);
plot(t,x);

Figure:

J.B. Institute of Engineering and Technology

DATE
PAGE NO:
NAME OF THE EXPERIMENT:

Sawtooth wave:

Program code:
clear all;
close all;
t=0:0.1:10;
x=sawtooth(t);
plot(t,x);

Figure:

J.B. Institute of Engineering and Technology

DATE
PAGE NO:
NAME OF THE EXPERIMENT:

Result: Hence the result of the basic programs are observed.

J.B. Institute of Engineering and Technology

DATE
PAGE NO:
NAME OF THE EXPERIMENT:
DISCRETE FOURIER TRANSFORM
AIM:

To find the DFT of given sequence using MATLAB

THEORY:
DFT of a finite sequence x(n) is defined as
N-1
X(K)= x(n) wNnk ,where W=e-j2
n=0
N=no.of samples in DFT
Working with the Fourier transform on a computer usually involves a form of the
transform known as the discrete Fourier Transform(DFT).There are two principal reasons for
using this form.The input and output of the DFT are both discrete,which makes it convenient
for computer manipulations

PROGRAM CODE:
clc; close all; clear all;
xn=input('enter the input sequence =');
L=length(xn);
N=input('Enter length of DFT sequence ');
if(N < L)
error('Length of DFT sequence must be greater than sequence length');
end
x1=[xn,zeros(1,N-L)];
y=zeros(1,N);
for k=0:1:N-1
for n=0:1:N-1
y(k+1)=y(k+1)+x1(n+1)*exp(-1i*2*pi*n*k/N);
end
end
disp('the result is');
display(y);
k=0:1:N-1;
subplot (2,1,1);
stem(k,x1);
xlabel ('n--->');
ylabel ('x(n)---->');
title('input sequence');
subplot (2,1,2);
stem(k,y);
xlabel ('k--->');
ylabel ('x(k)--->');
title('dft of the sequence');

OUTPUT:
enter the input sequence =[3 4 5 6]

J.B. Institute of Engineering and Technology

DATE
PAGE NO:
NAME OF THE EXPERIMENT:
Enter length of DFT sequence 6
the result is
y=
18.0000

-3.5000 - 7.7942i 4.5000 + 0.8660i

-2.0000 - 0.0000i 4.5000 - 0.8660i -3.5000 + 7.7942i

FIGURE:

RESULT:
Hence the result of the program,DFT of given sequence is observed.

J.B. Institute of Engineering and Technology

S-ar putea să vă placă și