Professional Documents
Culture Documents
m%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%
clear;
clc;
close all;
%+++++++++++++ASK MODULATION+++++++++++++++++++++++++
++++++
Fs=input('Enter the sampling Freq (# of samples) \n ');
N=input('Enter the length of Bit stream (Less than # of samples) \n ');
Tr_Sig=[];%Modulated Signal
M=2; k=log2(M); EbNo=5;
%GENERATE MESSAGE SIGNAL
Tb=1;
m=rand(1,N);
for i=1:N
if m(i)>0.5
m(i)=1;
else
m(i)=0;
end
end
for i=1:1:length(m)
Msg_Sig(((i-1)*Fs)+1:i*Fs)=m(i);
end
for i=1:length(Msg_Sig)
Msg_Sig1(i)=1-Msg_Sig(i);
end
%GENERATE CARRIER SIGNAL
fc1=10;fc2=20;
t=0:(1/Fs):(length(m)-(1/Fs));
% t=0:(Tb/Fs):Tb;
c1=sqrt(2/Tb)*sin(2*pi*fc1*t);
c2=0;
Tr_Sig=c1.*Msg_Sig+c2.*Msg_Sig1;
subplot(3,1,1)
plot(Msg_Sig)
title('Message Signal');xlabel('t'),ylabel('amp');
grid on ; axis([0 N*Fs -2 +2])
subplot(3,1,2)
plot(t,c1)
title('Carrier Signal 1');xlabel('t'),ylabel('amp');
grid on ; axis([0 1 -2 +2])
subplot(3,1,3)
plot(Tr_Sig)
title('Transmitted Signal');xlabel('t'),ylabel('amp');
grid on ; axis([0 N*Fs -2 +2])
% %+++++++++++++FSK MODULATION++++++++++++++++++++++++
+++++++
for i=1:10
msg_rx = awgn(Tr_Sig,EbNo+10*log10(k)-10*log10(Fs),...
% msg_rx=Tr_Sig;
Msg_Demod1(((j-1)*Fs)+1:j*Fs)=Msg_Demod(j);
end
[num,BER] = biterr(Msg_Sig,Msg_Demod1);
end
%l=length(a);
%figure,berfit(EbNo,a);
figure
subplot(2,1,1)
plot(msg_rx)
title('Received Signal');xlabel('t'),ylabel('amp');
grid on ; axis([0 N*Fs -2 +2])
subplot(2,1,2)
plot(Msg_Demod1)
title('Demodulated Signal');xlabel('t'),ylabel('amp');
grid on ; axis([0 N*Fs -2 +2])