%%%%%%%%%%% SURAJ BASTOLA %%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%% https://lnkd.in/gvdzPWX %%%%%%%%%%%%%
%%%%%%%%% RICEAN AND RAYLEIGH SIGNAL FADING %%%%%%%%%
clear all;
clc
close all;
%N = 10; % number of samples (bits) for transmission
k=1; %Ricean factor
SNR = 8; % SNR in dB
SNR1 = 10^(SNR./10); % or, SNR1 = 10^(SNR/10)
%disp(SNR1);
% Signal bit creation
[y,Fs] = audioread('C:\Users\suraj\OneDrive\Documents\MIT COLLEGE\Software Defined Radio Communication\MATLAB.wav');
subplot(2,2,1)
plot(y)
title('Original Audio Signal')
Sig_Bit = dec2bin( typecast( single(y), 'uint8'), 8 ) - '0';
Sig_Bit = reshape(Sig_Bit,1,[]);
N = 512;
SignalX = Sig_Bit(20000:20000+N-1);
%Sig_Bit = num2bin(y);
%Sig_Bit = randn(1,N)>0.5;
fprintf('Signal Created');
%disp(Sig_Bit);
%BPSK symbol
raw_signal = 2*SignalX-1;
fprintf('BPSK SYMBOL');
subplot(2,2,2)
plot(raw_signal)
title('Raw BPSK Signal')
%disp(raw_signal);
n = 1./sqrt(2)*(randn(1,N) + 1j*randn(1,N));%Noise creation(AWGN, 0dB variance )
%================== RAYLEIGH CHANNEL ================================
ch_ray = 1./sqrt(2)*(randn(1,N)+1i*randn(1,N));
% Faded signal with Rayleigh channel
Sig_fad_ray = ch_ray.* raw_signal + SNR1.*n;
subplot(2,2,3)
plot(Sig_fad_ray)
title('Faded Rayleigh Signal')
%====================================================
% equalization (ideal)
Sig_fad_ray1 = Sig_fad_ray./ch_ray;
fprintf('Rayleigh Faded Signal Received at the receiver');
%disp(Sig_fad_ray1);
fprintf('Absolute value of Faded Signal Received at the receiver');
%disp(abs(Sig_fad_ray1));
%================== RICEAN CHANNEL ================================
% Ricean Channel
ch_ric = sqrt(k/(k+1))+sqrt(1/(k+1))*(1/sqrt(2))*(randn(1,N)+1j*randn(1,N));
Sign_fad_ric = ch_ric.*raw_signal+10^(-SNR/20)*n;
% equalization (ideal)
Sig_fad_ric1 = Sign_fad_ric./ch_ric;
fprintf('Faded Signal Received at the receiver');
%disp(Sig_fad_ric1);
fprintf('Absolute value of Faded Signal Received at the receiver');
%disp(abs(Sig_fad_ric1));
subplot(2,2,4)
plot(Sig_fad_ric1)
title('Faded Ricean Signal')
% receiver - hard decision decoding
for i = 1: N
if real(Sig_fad_ray1(i)) > 0
Sig_ray_Rayleigh(i) = 1;
else
Sig_ray_Rayleigh(i) = 0;
end
end
% receiver - hard decision decoding
for i = 1: N
if real(Sig_fad_ric1(i)) > 0
Sig_ray_Rec(i) = 1;
else
Sig_ray_Rec(i) = 0;
end
end
% Measuring the errors: Compare original signal with
Err_num_ray1 = size(find([SignalX- Sig_ray_Rayleigh]),2);
BER_ray1 = Err_num_ray1 /N;
fprintf('Rayleigh BER = ');
disp(BER_ray1);
Recian = size(find([SignalX- Sig_ray_Rec]),2);
BER_Recian = Recian /N;
fprintf('Ricean BER= ');
disp(BER_Recian);
Thanks for the help.
ReplyDeleteNo worries. I am always happy to help in need.
ReplyDelete