Sie sind auf Seite 1von 32

AMPLITUDE MODULATION

Ex No: 1
Date:
AIM:
To write a MATLAB code to generate an amplitude modulated waveform.
ALGORITHM:
Step 1: Start.
Step 2: Generate the amplitude modulated wave.
Step 3: Plot the output.
Step 4: Stop.
PROGRAM:
clc;clf;close all;clear all;
t=0.1:0.001:1;
m=5*sin(2*pi*10*t);
subplot(3,1,1);
plot(m);
grid on;
title('SIGNAL');
xlabel('frequency');
ylabel('amplitude');
c=5*cos(2*pi*100*t);
subplot(3,1,2);
plot(c);
grid on;
title('CARRIER');
xlabel('frequency');
ylabel('amplitude');
x=5/5;
disp(x);
a=(1+x.*(sin(2*pi*10*t))).*cos(2*pi*100*t);
subplot(3,1,3);
plot(a);
grid on;
title('AM SIGNAL');
xlabel('frequency');
ylabel('amplitude');
OUTPUT:
RESULT:
Thus an amplitude modulated waveform was generated using MATLAB.
FREQUENCY MODULATION
Ex No: 2
Date:
AIM:
To write a MATLAB code to generate a frequency modulated waveform.
ALGORITHM:
Step 1: Start.
Step 2: Get the parameter required to design a frequency modulation as inputs.
Step 3: Generate the frequency modulated wave.
Step 4: Plot the waveform and label it.
Step 5: Stop.
PROGRAM:
clc;clf;close all;clear all;
t=0.1:0.001:.5;
fm=input('Enter the fm value= ');
m=5*sin(2*pi*fm*t);
subplot(3,1,1);
plot(m);
grid on;
title('SIGNAL');
xlabel('frequency');
ylabel('amplitude');
c=5*cos(2*pi*100*t);
subplot(3,1,2);
plot(c);
grid on;
title('CARRIER');
xlabel('frequency');
ylabel('amplitude');
k=input('Enter the frequency sensitivity= ');
x=k/fm;
f=5*cos((2*pi*100*t)+x.*sin(2*pi*fm*t));
subplot(3,1,3);
plot(f);
grid on;
title('FM SIGNAL');
xlabel('frequency');
ylabel('amplitude');
INPUT:
Enter the fm value= 10
Enter the frequency sensitivity= 100
OUTPUT:
RESULT:
Thus a frequency modulated waveform was generated using MATLAB.
AMPLITUDE SHIFT KEYING
Ex No: 3
Date:
AIM:
To generate an Amplitude shift keying waveform using MATLAB.
ALGORITHM:
Step 1: Start.
Step 2: Get the parameters required to generate an ASK waveform as inputs.
Step 3: Set the time period for amplitude shift of ASK.
Step 4: Generate the wave forms.
Step 5: Plot the waves.
Step 6: Stop.
PROGRAM:
clc;clf;clear all;close all;
b=input('Enter the bits ');
t=0:0.0004:length(b);
a=input('Enter the value of amplitude ');
f=input('Enter the value of frequency ');
s=a*sin(2*pi*f*t);
sq=a*sin(2*pi*f*t);
subplot(3,1,2);
plot(t,s);
title('CARRIER SIGNAL');
j=1;
for i=1:length(t)
if t(i)<j
s(i)=s(i)*b(j);
sq(i)=b(j);
else
j=j+1;
end
end
subplot(3,1,3);
plot(t,s);
title('ASK');
xlabel('time');
ylabel('amplitude');
subplot(3,1,1);
plot(t,sq);
title('BINARY SIGNAL');
INPUT:
Enter the input bit [1 0 1 0 1]
Enter the carrier amplitude 5
Enter the carrier frequency 10
OUTPUT:
RESULT:
Thus the above code is entered, executed and the output has been verified.
FREQUENCY SHIFT KEYING
Ex No: 4
Date:
AIM:
To generate a Frequency shift keying waveform using MATLAB.
ALGORITHM:
Step 1: Start.
Step 2: Get the parameters required to generate an FSK waveform as inputs.
Step 3: Set the frequency for frequency shift of FSK.
Step 4: Generate the wave forms.
Step 5: Plot the waves.
Step 6: Stop.
PROGRAM:
clc;clf;clear all;close all;
a=input('Enter the amplitude ');
b=input('Enter the number of bits ');
t=0:0.0004:length(b);
f1=input('Frequency corresponding to bit 0 ');
f2=input('Frequency corresponding to bit 1 ');
s=a*sin(2*pi*f1*t);
v=a*sin(2*pi*f2*t);
sq=a*sin(2*pi*f1*t);
subplot(3,1,1);
plot(s);
title('CARRIER SIGNAL 1');
subplot(3,1,2);
plot(v);
title('CARRIER SIGNAL 2');
j=1;
for i=1:length(t)
if t(i)<j
if b(j)==1
s(i)=s(i);
sq(j)=b(j);
else
s(i)=v(i);
sq(i)=b(j);
end
else
j=j+1;
end
end
subplot(3,1,3);
plot(s);
xlabel('frequency');
ylabel('amplitude');
title('FSK');
INPUT:
Enter the amplitude 5
Enter the number of bits [1 0 1 0 1]
Frequency corresponding to bit 0= 1
Frequency corresponding to bit 1= 10
OUTPUT:
RESULT:
Thus the above code is entered, executed and the output has been verified.
FIR LOW PASS FILTER
Ex No: 5
Date:
AIM:
To write a MATLAB code to design a low pass filter using hamming window
function.
ALGORITHM:
Step 1: Start.
Step 2: Calculate the order of the filter.
Step 3: Get the cutoff frequency.
Step 4: Find the window coefficient.
Step 5: Plot the output.
Step 6: Stop.
PROGRAM:
clc;clf;clear all;close all;
N=input('Enter the order of filter= ');
wcl=input('Enter the cutoff frequency of LPF= ');
% LPF
% y=rectwin(N+1);%rectangular window
% y=triang(N+1);%triangular window
% y=hanning(N+1);%hanning window
% y=blackman(N+1);%blackman window
y=hamming(N+1);%hamming window
% y=boxcar(N+1);%boxcar window
% y=bartlett(N+1);%bartlett window
a=fir1(N,wcl,y);
[h wcl]=freqz(a,1,256);
mag1=20*log10(abs(h));
phase1=angle(h);
plot(wcl/pi,mag1);
grid on;
title('LPF');
xlabel('frequency in radian');
ylabel('gain in db');
INPUT:
Enter the order of filter= 50
Enter the cutoff frequency of LPF= 0.5
OUTPUT:
RESULT:
Thus the program to design a FIR low pass filter using Hamming window is done and
output has been verified.
FIR HIGH PASS FILTER
Ex No: 6
Date:
AIM:
To write a MATLAB code to design a high pass filter using hamming window
function.
ALGORITHM:
Step 1: Start.
Step 2: Calculate the order of the filter.
Step 3: Get the cutoff frequency.
Step 4: Find the window coefficient.
Step 5: Plot the output.
Step 6: Stop.
PROGRAM:
clc;clf;clear all;close all;
N=input('Enter the order of filter= ');
wch=input('Enter the cutoff frequency of HPF= ');
% HPF
% y=rectwin(N+1);%rectangular window
% y=triang(N+1);triangular window
% y=hanning(N+1);%hanning window
% y=blackman(N+1);%blackman window
y=hamming(N+1);%hamming window
% y=boxcar(N+1);%boxcar window
% y=bartlett(N+1);%bartlett window
a=fir1(N,wch,'high',y);
[h wch]=freqz(a,1,256);
mag2=20*log10(abs(h));
phase2=angle(h);
plot(wch/pi,mag2);
grid on;
title('HPF');
xlabel('frequency in radian');
ylabel('gain in db');
INPUT:
Enter the order of filter= 50
Enter the cutoff frequency of HPF= 0.5
OUTPUT:
RESULT:
Thus the program to design a FIR high pass filter using Hamming window is done
and output has been verified.
FIR BAND PASS FILTER
Ex No: 7
Date:
AIM:
To write a MATLAB code to design a band pass filter using hamming window
function.
ALGORITHM:
Step 1: Start.
Step 2: Calculate the order of the filter.
Step 3: Get the cutoff frequencies.
Step 4: Find the window coefficient.
Step 5: Plot the output.
Step 6: Stop.
PROGRAM:
clc;clf;clear all;close all;
N=input('Enter the order of filter=');
wc1=input('Enter the lower cutoff frequency=');
wc2=input('Enter the higher cutoff frequency=');
% BPF
% y=rectwin(N+1);%rectangular window
% y=triang(N+1);%triangular window
% y=hanning(N+1);%hanning window
% y=blackman(N+1);%blackman window
y=hamming(N+1);%hamming window
% y=boxcar(N+1);%boxcar window
% y=bartlett(N+1);%bartlett window
wcbp=([wc1 wc2]);
a=fir1(N,wcbp,y);
[h wcbp]=freqz(a,1,256);
mag3=20*log10(abs(h));
phase3=angle(h);
plot(wcbp/pi,mag3);
grid on;
title('BPF');
xlabel('frequency in radian');
ylabel('gain in db');
INPUT:
Enter the order of filter=50
Enter the lower cutoff frequency=0.3
Enter the higher cutoff frequency=0.7
OUTPUT:
RESULT:
Thus the program to design a FIR band pass filter using Hamming window is done
and output has been verified.
FIR BAND STOP FILTER
Ex No: 8
Date:
AIM:
To write a MATLAB code to design a band stop filter using hamming window
function.
ALGORITHM:
Step 1: Start.
Step 2: Calculate the order of the filter.
Step 3: Get the cutoff frequencies.
Step 4: Find the window coefficient.
Step 5: Plot the output.
Step 6: Stop.
PROGRAM:
clc;clf;clear all;close all;
N=input('Enter the order of filter=');
wc1=input('Enter the lower cutoff frequency=');
wc2=input('Enter the higher cutoff frequency=');
% BSF
% y=rectwin(N+1);%rectangular window
% y=triang(N+1);%triangular window
% y=hanning(N+1);%hanning window
% y=blackman(N+1);%blackman window
y=hamming(N+1);%hamming window
% y=boxcar(N+1);%boxcar window
% y=bartlett(N+1);%bartlett window
wcbs=([wc1 wc2]);
a=fir1(N,wcbs,'stop',y);
[h wcbs]=freqz(a,1,256);
mag4=20*log10(abs(h));
phase4=angle(h);
plot(wcbs/pi,mag4);
grid on;
title('BSF');
xlabel('frequency in radian');
ylabel('gain in db');
INPUT:
Enter the order of filter=50
Enter the lower cutoff frequency=0.4
Enter the higher cutoff frequency=0.5
OUTPUT:
RESULT:
Thus the program to design a FIR band stop filter using Hamming window is done
and output has been verified.
HISTOGRAM EQUALIZATION
Ex No: 9
Date:
AIM:
To write a MATLAB code for constructing the histogram of an image and also
equalizing the image.
ALGORITHM:
Step 1: Start.
Step 2: Display the original image.
Step 3: The picture is equalized after the histogram is constructed.
Step 4: Plot the histogram of original image and equalized image.
Step 5: Stop.
PROGRAM:
clc;clf;clear all;close all;
subplot(2,2,1);
a=imread('C:\pictures\TAJ.jpg');
imshow(a);
title('ORIGINAL IMAGE');
subplot(2,2,2);
imhist(a(:,:,1));
title('HISTOGRAM OF ORIGINAL IMAGE');
subplot(2,2,3);
j=rgb2gray(a);
b=histeq(j);
imshow(b);
title('EQUALIZED IMAGE');
subplot(2,2,4);
imhist(b,64);
title('HISTOGRAM OF EQUALIZED IMAGE');
OUTPUT:
RESULT:
Thus the MATLAB code for performing histogram equalization has been written and
executed.
MULTIPLEXING AND DEMULTIPLEXING
Ex No: 10
Date:
AIM:
To write a MATLAB code to multiplexing and de-multiplexing four signals .
ALGORITHM:
Step 1: Start.
Step 2: Generate four input sine and cosine signals.
Step 3: Sample the signals.
Step 4: Multiplex and demultiplex the signals.
Step 5: Plot the output.
Step 6: Stop.
PROGRAM:
clc;
close all;

% Signal generation
x=0:0.01:1; % siganal taken upto 4pi

sig1=8*sin(2*3.14*1*x); % generate 1st sinusoidal signal
sig2=8*cos(2*3.14*1*x); % Generate 1st cosine Sigal
sig3=1*sin(2*3.14*1*x); % generate 2nd sinusoidal signal
sig4=2*cos(2*3.14*1*x); % Generate 2nd cosine Sigal

% To Display signals
subplot(4,2,1);
plot(sig1,'red');
title('sin1 Signal');
ylabel('Amplitude--->');
xlabel('Time--->');

subplot(4,2,3);
plot(sig2,'blue');
title('cos1 Signal');
ylabel('Amplitude--->');
xlabel('Time--->');

subplot(4,2,5);
plot(sig3,'yellow');
title('sin2 Signal');
ylabel('Amplitude--->');
xlabel('Time--->');

subplot(4,2,7);
plot(sig4,'green');
title('cos2 Signal');
ylabel('Amplitude--->');
xlabel('Time--->');

% TO Display Sampled Signals
subplot(4,2,2);
stem(sig1);
title('Sampled sin1 Signal');
ylabel('Amplitude--->');
xlabel('Time--->');
subplot(4,2,4);

stem(sig2);
title('Sampled cos1 Signal');
ylabel('Amplitude--->');
xlabel('Time--->');

subplot(4,2,6);
stem(sig3);
title('Sampled sin2 Signal');
ylabel('Amplitude--->');
xlabel('Time--->');

subplot(4,2,8);
stem(sig3);
title('Sampled cos2 Signal');
ylabel('Amplitude--->');
xlabel('Time--->');

l1=length(sig1);
l2=length(sig2);
l3=length(sig3);
l4=length(sig4);

for i=1:l1
sig(1,i)=sig1(i); % Making Both row vector to a matrix
sig(2,i)=sig2(i);
sig(3,i)=sig3(i);
sig(4,i)=sig4(i);
end

% TDM of both quantize signal
tdmsig=reshape(sig,1,4*l1);

% Display of TDM Signal
figure
stem(tdmsig);
title('TDM Signal');
ylabel('Amplitude--->');
xlabel('Time--->');

% Demultiplexing of TDM Signal
demux=reshape(tdmsig,4,l1);
for i=1:l1
sig5(i)=demux(1,i); % Converting The matrix into row vectors
sig6(i)=demux(2,i);
sig7(i)=demux(3,i);
sig8(i)=demux(4,i);
end

% display of demultiplexed signal
figure
subplot(4,1,1)
plot(sig4);
title('Recovered Sinusoidal Signal');
ylabel('Amplitude--->');
xlabel('Time--->');

subplot(4,1,2)
plot(sig5);
title('Recovered cos1 Signal');
ylabel('Amplitude--->');
xlabel('Time--->');

subplot(4,1,3)
plot(sig6);
title('Recovered cosine Signal');
ylabel('Amplitude--->');
xlabel('Time--->');

subplot(4,1,4)
plot(sig6);
title('Recovered cos2 Signal');
ylabel('Amplitude--->');
xlabel('Time--->');
OUTPUT:
0 20 40 60 80 100 120
-10
0
10
sin1 Signal
A
m
p
l
i
t
u
d
e
-
-
-
>
Time--->
0 20 40 60 80 100 120
-10
0
10
cos1 Signal
A
m
p
l
i
t
u
d
e
-
-
-
>
Time--->
0 20 40 60 80 100 120
-1
0
1
sin2 Signal
A
m
p
l
i
t
u
d
e
-
-
-
>
Time--->
0 20 40 60 80 100 120
-2
0
2
cos2 Signal
A
m
p
l
i
t
u
d
e
-
-
-
>
Time--->
0 20 40 60 80 100 120
-10
0
10
Sampled sin1 Signal
A
m
p
l
i
t
u
d
e
-
-
-
>
Time--->
0 20 40 60 80 100 120
-10
0
10
Sampled cos1 Signal
A
m
p
l
i
t
u
d
e
-
-
-
>
Time--->
0 20 40 60 80 100 120
-1
0
1
Sampled sin2 Signal
A
m
p
l
i
t
u
d
e
-
-
-
>
Time--->
0 20 40 60 80 100 120
-1
0
1
Sampled cos2 Signal
A
m
p
l
i
t
u
d
e
-
-
-
>
Time--->
0 50 100 150 200 250 300 350 400 450
-8
-6
-4
-2
0
2
4
6
8
TDM Signal
A
m
p
l
i
t
u
d
e
-
-
-
>
Time--->
0 20 40 60 80 100 120
-2
0
2
Recovered Sinusoidal Signal
A
m
p
l
i
t
u
d
e
-
-
-
>
Time--->
0 20 40 60 80 100 120
-10
0
10
Recovered cos1 Signal
A
m
p
l
i
t
u
d
e
-
-
-
>
Time--->
0 20 40 60 80 100 120
-10
0
10
Recovered cosine Signal
A
m
p
l
i
t
u
d
e
-
-
-
>
Time--->
0 20 40 60 80 100 120
-10
0
10
Recovered cos2 Signal
A
m
p
l
i
t
u
d
e
-
-
-
>
Time--->
RESULT:
Thus the program for multiplexing and demultiplexing signals are done using matlab.
LABVIEW
JK FLIPFLOP
Ex no:11
Date:
AIM:
To design JK flipflop using Labview.
ALGORITHM:
1.Start.
2.Open labview window.
3.Drag the required number of NAND gates and drop it on the user window.
4.Drag the required number of switches and LEDs and drop it on the system window.
5. Do the appropriate connections.
6.Click run .
7.Stop.
BLOCK DIAGRAM:
OUTPUT:
J K
Output
0 0 Previous
state
0 1 0
1 0 1
1 1 toggle
RESULT:
Thus JK flipflop has been designed using labview and the output has been verified.
D FLIPFLOP
Ex no:12
Date:
AIM:
To design D flipflop using Labview.
ALGORITHM:
1.Start.
2.Open labview window.
3.Drag the required number of NAND gates and NOT gate and drop it on the user
window.
4.Drag the required number of switches and LEDs and drop it on the system window.
5. Do the appropriate connections.
6.Click run .
7.Stop.
BLOCK DIAGRAM:
OUTPUT:
RESULT:
Thus D flipflop has been designed using labview and the output has been verified.
D CLOCK Q Q
1 1 1 0
0 1 0 1
SR FLIPFLOP
Ex no:13
Date:
AIM:
To design SR flipflop using Labview.
ALGORITHM:
1.Start.
2.Open labview window.
3.Drag the required number of NAND gates and drop it on the user window.
4.Drag the required number of switches and LEDs and drop it on the system window.
5. Do the appropriate connections.
6.Click run .
7.Stop.
BLOCK DIAGRAM:
OUTPUT:
S R
Output
0 0 1
0 1 0
1 0 1
1 1 0
RESULT:
Thus SR flipflop has been designed using labview and the output has been verified.

Das könnte Ihnen auch gefallen