% Exercise 3.4
LN1 = 9; % Number 1 of sinusoids
LN2 = 10; % Number 2 of sinusoids
Lb = 1; % Variance of ^gi(t)
Lfm = 91; % Maximum Doppler frequency
Lfs = 50*10^3; % Sampling frequency
LTsim = 20; % Simulation time
Lt = 0:1/Lfs:LTsim; % Time t
Lg1t = git(Lb, Lfm, LN1, Lt); % ^g1(t)
Lg2t = git(Lb, Lfm, LN2, Lt); % ^g2(t)
Lgt = Lg1t + Lg2t*i; % ^g(t)
Lat = abs(Lgt); % ^a(t)
meanOfLg1t = mean(Lg1t) % mean of ^g1(t)
varOfLg1t = var(Lg1t) % variance of ^g1(t)
meanOfLgt = mean(Lgt) % mean of ^g(t)
varOfLgt = var(Lgt) % variance of ^g(t)
meanOfLat = mean(Lat) % mean of ^a(t)
varOfLat = var(Lat) % variance of ^a(t)
figure(41);
subplot(1, 2, 1);
hist(Lg1t, 10000);
title('Histogram of g1(t)');
xlabel('Value of g1(t)');
ylabel('Numbers of value');
% Gaussian distribution
subplot(1, 2, 2);
hist(Lat, 10000);
title('Histogram of a(t)');
xlabel('Value of a(t)');
ylabel('Numbers of value');
% Rayleigh distribution
% Compare the PDF of ^g1(t) with the theoretical result given in (1.1)
Lmu = 0; % mu
Lbu = 1; % bu
Lx = -4:.05:4; % Interval of PDF
theoPDF = my_pdf(Lmu, Lbu, Lt); % PDF of theoretical result given in (1.1)
figure(42);
subplot(1, 2, 1);
plot(Lt, theoPDF);
title('PDF of Theoretical Result in (1.1)');
xlabel('Interval of PDF');
ylabel('Value of PDF');
subplot(1, 2, 2);
% hist(Lg1t);
PDFLg1t = my_pdf(meanOfLg1t, sqrt(varOfLg1t), Lt); % PDF of ^g1(t)
plot(PDFLg1t);
title('PDF of g1(t)');
xlabel('Interval of PDF');
ylabel('Value of PDF');
% Compare the PDF of ^a(t) with the theoretical result pa(x) given in (2.4)
LNp = 2; % Total received power
LK = 0; % K is the Rice factor
% Lx2 = 0:.05:10;
theoPa2 = pa(Lt, LK, LNp); % PDF of theoretical result pa(x) in (2.4)
figure(43);
subplot(1, 2, 1);
plot(Lt, theoPa2);
title('PDF of Theoretical Result in (2.4)');
xlabel('Interval of PDF');
ylabel('Value of PDF');
subplot(1, 2, 2);
hist(Lat, 10000);
% PDFLat = my_pdf(meanOfLat, varOfLat, Lx); % PDF of ^a(t)
% plot(PDFLat);
title('PDF of a(t)');
xlabel('Interval of PDF');
ylabel('Value of PDF');