ADCS Matlab Programs
ADCS Matlab Programs
Aim: To generate and demodulate frequency shift keyeing (FSK) signal using MATLAB
Apparatus:
*PC with windows xp operating system
*matlab software version 7.6
procedure: *
*open the matlab software on the desktop by double clicking on it
*select M-file from new option in file menu
*now enter program code & save it
*press the f5 key for simulation of program & obtaining respective waveforms
*plot the obtained waveforms
program:
% FSK Modulation
clc;
clear all;
close all;
%Multiplier
fsk_sig1(i,:)=c1.*m_s;
fsk_sig2(i,:)=c2.*invm_s;
fsk=fsk_sig1+fsk_sig2;
subplot(3,2,2);axis([0 N -2 2]);plot(t,message(i,:),'r');
title('message signal');xlabel('t---->');ylabel('m(t)');grid on;hold on;
subplot(3,2,5);plot(t,fsk(i,:));
title('FSK signal');xlabel('t---->');ylabel('s(t)');grid on;hold on;
t1=t1+(Tb+.01); t2=t2+(Tb+.01);
end
hold off
% FSK Demodulation
t1=0;t2=Tb
for i=1:N
t=[t1:(Tb/100):t2]
%correlator
x1=sum(c1.*fsk_sig1(i,:));
x2=sum(c2.*fsk_sig2(i,:));
x=x1-x2;
%decision device
if x>0
demod(i)=1;
else
demod(i)=0;
end
t1=t1+(Tb+.01);
t2=t2+(Tb+.01);
end
Output waveforms:
Result:
Aim: To generate and demodulate quadrature phase shifted (QPSK) signal using MATLAB
Apparatus:
*window &xp operating system
*matlab software version 7.6
Procedure:
*open the matlab software on the desktop by double clicking on it
*select M-file from new option in file menu
*now enter program code & save it
*press the f5 key for simulation of program & obtaining respective waveforms
*plot the obtained waveforms
Program:
% QPSK Modulation
clc;
clear all;
close all;
% QPSK Demodulation
t1=0;t2=Tb
for i=1:N-1
t=[t1:(Tb/100):t2]
%correlator
x1=sum(c1.*qpsk(i,:));
x2=sum(c2.*qpsk(i,:));
%decision device
if (x1>0&&x2>0)
demod(i)=1;
demod(i+1)=1;
elseif (x1>0&&x2<0)
demod(i)=1;
demod(i+1)=0;
elseif (x1<0&&x2<0)
demod(i)=0;
demod(i+1)=0;
elseif (x1<0&&x2>0)
demod(i)=0;
demod(i+1)=1;
end
t1=t1+(Tb+.01); t2=t2+(Tb+.01);
end
subplot(3,2,5);stem(demod);
title('qpsk demodulated bits');xlabel('n---->');ylabel('b(n)');grid on;
Result:
Apparatus:
*PC with windows xp operating system
*matlab software version 7.6
Procedure:
*open the matlab software on the desktop by double clicking on it
*select M-file from new option in file menu
*now enter program code & save it
*press the f5 key for simulation of program & obtaining respective wave forms
*plot the obtained waveforms
Program:
N = 10^4
Output Waveforms
Bit error probability curve for coherent demodulation of DBPSK
theory
simulation
-1
10
-2
10
Bit Error Rate
-3
10
-4
10
-5
10
-6
10
-2 0 2 4 6 8 10
Eb/No, dB
Result
Apparatus:
*PC with windows xp operating system
*matlab software version 7.6
Procedure:
*open the matlab software on the desktop by double clicking on it
*select M-file from new option in file menu
*now enter program code & save it
*press the f5 key for simulation of program & obtaining respective wave forms
*plot the obtained waveforms
Program
function [y MSE]=Delta_Modulation(del, A)
%del=step size
%A=amplitude of signal
end
stairs(xr)
hold off
MSE=sum((x-xr).^2)length(x)
end
Output waveforms:
Result:
Gates Institute of Technology, Gooty.
Date: Page no:
Apparatus:
*PC with windows xp operating system
*matlab software version 7.6
Procedure:
*open the matlab software on the desktop by double clicking on it
*select M-file from new option in file menu
*now enter program code & save it
*press the f5 key for simulation of program & obtaining respective wave forms
*plot the obtained waveforms
Program:
clc;
close all;
clear all;
% Signal generation
x=0:.5:4*pi; % siganal taken upto 4pi
Output waveforms:
Result:
Apparatus:
*PC with windows xp operating system
*matlab software version 7.6
Procedure:
*open the matlab software on the desktop by double clicking on it
*select M-file from new option in file menu
*now enter program code & save it
*press the f5 key for simulation of program & obtaining respective wave forms
*plot the obtained waveforms
Program
clc;
close all;
clear all;
n=input('Enter n value for n-bit PCM system : ');
n1=input('Enter number of samples in a period : ');
L=2^n;
% % Signal Generation
% x=0:1/100:4*pi;
% y=8*sin(x); % Amplitude Of signal is 8v
% subplot(2,2,1);
% plot(x,y);grid on;
% Sampling Operation
x=0:2*pi/n1:4*pi; % n1 number of samples have tobe selected
s=8*sin(x);
subplot(3,1,1);
plot(s);
title('Analog Signal');
ylabel('Amplitude--->');
xlabel('Time--->');
subplot(3,1,2);
stem(s);grid on; title('Sampled Signal'); ylabel('Amplitude--->'); xlabel('Time--->');
% Quantization Process
vmax=8;
vmin=-vmax;
del=(vmax-vmin)/L;
part=vmin:del:vmax; % level are between vmin and vmax with difference of del
code=vmin-(del/2):del:vmax+(del/2); % Contaion Quantized valuses
[ind,q]=quantiz(s,part,code); % Quantization process
% ind contain index number and q contain quantized values
l1=length(ind);
l2=length(q);
for i=1:l1
if(ind(i)~=0) % To make index as binary decimal so started from 0 to N
ind(i)=ind(i)-1;
end
i=i+1;
end
for i=1:l2
if(q(i)==vmin-(del/2)) % To make quantize value inbetween the levels
q(i)=vmin+(del/2);
end
end
subplot(3,1,3);
stem(q);grid on; % Display the Quantize values
title('Quantized Signal');
ylabel('Amplitude--->');
xlabel('Time--->');
% Encoding Process
figure
code=de2bi(ind,'left-msb'); % Cnvert the decimal to binary
k=1;
for i=1:l1
for j=1:n
coded(k)=code(i,j); % convert code matrix to a coded row vector
j=j+1;
k=k+1;
end
i=i+1;
end
subplot(2,1,1); grid on;
stairs(coded); % Display the encoded signal
axis([0 100 -2 3]); title('Encoded Signal');
ylabel('Amplitude--->');
xlabel('Time--->');
qunt=reshape(coded,n,length(coded)/n);
index=bi2de(qunt','left-msb'); % Getback the index in decimal form
q=del*index+vmin+(del/2); % getback Quantized values
subplot(2,1,2); grid on;
plot(q); % Plot Demodulated signal
title('Demodulated Signal');
ylabel('Amplitude--->');
xlabel('Time--->');
Output waveforms
Result: