Lab2 2 8
Lab2 2 8
eta_Tx_dB=0.55;
P_Tx_dB=-40;
freq_rf=6e9;
eta_Tx=0.55;
dia_Tx=1;
B=125*1e6;
distance=1000;
F_f=0.005;
dia_Rx=0.1;
eta_Rx=0.5;
temp=298;
bolts_k=1.380649e-23;
c=3e8;
%Q:2.a
t=0:1:100;
Lf_dB=25*sin(2*pi*F_f*t);
plot(t,Lf_dB,'LineWidth',2);
grid on;
xlabel('Time');
ylabel('Additional Loss');
%Q:2.b
%EIRP_dB=P_Tx_dB+ant_gain_Tx_dB
%RIP_dB=EIRP_dB-fspl_dB-Lf_dB (RIP->Received isotropic power)
1
%Prx_dB=RIP_dB+ant_gain_rx_dB
%Es_dB=Prx_dB-B_dB
%SNR=Es_dB-N0_dB
lemda_rf=c/freq_rf;
ant_gain_Tx=eta_Tx * (((pi*dia_Tx)/lemda_rf)^2);
ant_gain_Tx_dB=10*log10(ant_gain_Tx);
EIRP_dB=P_Tx_dB+ant_gain_Tx_dB;
fspl=((4*pi*distance)/lemda_rf)^2;
fspl_dB=10*log10(fspl);
RIP_dB=EIRP_dB-fspl_dB-Lf_dB;
ant_gain_Rx=eta_Rx*(((pi*dia_Rx)/lemda_rf)^2);
ant_gain_Rx_dB=10*log10(ant_gain_Rx);
Prx_dB=RIP_dB+ant_gain_Rx_dB;
B_dB=10*log10(band);
Es_dB=Prx_dB-B_dB;
bolts_k_dB=10*log10(bolts_k);
temp_dB=10*log10(temp);
N0_dB=bolts_k_dB+temp_dB;
SNR_dB=Es_dB-N0_dB;
%(c)
MODCOD=readtable('dvbs2modcods.xlsx');
Warning: Column headers from the file were modified to make them valid MATLAB identifiers
before creating variable names for the table. The original column headers are saved in the
VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.
EsNoAWGN_name='EsNoAWGN';
SpectralEfficiency_name='SpectralEfficiency';
EsNoAWGN=MODCOD.(EsNoAWGN_name);
SpectralEfficiency=MODCOD.(SpectralEfficiency_name);
SNR_dB_nearest=zeros(size(SNR_dB));
eta_B=zeros(size(SNR_dB));
for i = 1:length(SNR_dB)
ans = 10000;
c= SNR_dB(i);
e=0;
for j = 1:length(EsNoAWGN);
curr = EsNoAWGN(j);
ef=SpectralEfficiency(j);
diff=abs(c-curr);
2
if diff<ans
ans=diff;
e=ef;
end
end
SNR_dB_nearest(i)=ans;
eta_B(i)=e;
end
%(d)
data_rate=eta_B.*B;
plot(t,data_rate/1e9,'linewidth',2);
xlabel('Time in sec');
ylabel('Msps');
title('Achieved Data rate over 125MHz');
3
% MIMO Concept
%q-1
NR = 8;
NT = 16;
H = randn(NR, NT)+11*randn(NR, NT);
H = H/sqrt(2);
disp("MIMO channel matrix H")
disp(H)
5.8369 -7.8433 -6.5543 0.0752 -3.0407 -1.4454 -0.2403 3.7554 -1.2657 1.2891 -0.
-14.6626 10.7281 -6.5631 -5.4766 -7.1677 5.9850 2.2131 8.3448 0.2400 -7.3814 -0.
-4.3496 1.7692 -7.9984 8.4375 -10.7945 -10.1348 -4.3143 -8.8527 -0.6558 6.8424 -3.
-5.7964 -0.1802 -3.1480 -1.2508 20.6648 -17.9009 6.7597 10.5957 5.9004 1.3968 14.
-12.0412 0.6910 -15.1020 -5.3499 13.1067 -11.8829 -11.4500 4.3646 11.1264 0.0456 -7.
3.0264 -2.0824 6.6461 9.9546 1.8582 2.5729 2.7519 -0.5048 5.2938 4.3529 -3.
1.8867 -13.1081 4.5523 -1.1201 -8.8091 2.9274 -6.6063 -1.1278 -2.0665 1.9078 -4.
0.5027 -2.3668 0.9970 -5.3927 -7.9420 3.9571 -1.5211 -0.9143 5.3918 -7.4617 -9.
Es = 1;
M = 16;
s_psk = sqrt(Es)*exp(1i*(0:M-1)*2*pi/M);
%Q-3
Nr_sys=s_psk(randperm(M,NR));
x = zeros(NT, 1);
x(1 : NR) = Nr_sys;
disp("Vector X")
Vector X
disp(x)
-0.0000 - 1.0000i
-0.7071 - 0.7071i
-0.3827 + 0.9239i
0.3827 - 0.9239i
-0.9239 - 0.3827i
0.9239 - 0.3827i
-0.9239 + 0.3827i
-0.3827 - 0.9239i
0.0000 + 0.0000i
0.0000 + 0.0000i
0.0000 + 0.0000i
0.0000 + 0.0000i
0.0000 + 0.0000i
0.0000 + 0.0000i
0.0000 + 0.0000i
0.0000 + 0.0000i
%Q - 4
disp("Vector Y")
Vector Y
y = H*x;
disp(y)
1
8.3418 - 8.2605i
-0.2567 - 0.3371i
13.0218 + 2.4509i
-45.0765 - 4.0891i
-10.9358 - 6.3396i
1.0496 - 4.7868i
24.4762 +13.3873i
11.9769 + 8.8617i
%Q-5
%comparing elemnts of y and x is diffrent due to H matrix
%Q-6
[U,S,V]=svd(H);
disp("U Matrix:");
U Matrix:
disp(U)
disp("S Matrix:")
S Matrix:
disp(S)
45.6406 0 0 0 0 0 0 0 0 0
0 40.4238 0 0 0 0 0 0 0 0
0 0 30.4524 0 0 0 0 0 0 0
0 0 0 25.5607 0 0 0 0 0 0
0 0 0 0 22.0945 0 0 0 0 0
0 0 0 0 0 17.7481 0 0 0 0
0 0 0 0 0 0 14.6728 0 0 0
0 0 0 0 0 0 0 12.7182 0 0
disp("V Matrix:")
V Matrix:
disp(V)
0.3153 -0.0421 -0.3546 0.3046 -0.2938 0.2018 -0.1518 0.2773 -0.0246 0.0258 0.
-0.1751 0.0783 -0.0067 -0.3851 0.5375 -0.0888 -0.3659 0.3414 -0.1712 0.2169 0.
0.3114 -0.0345 -0.4478 -0.0187 0.0212 -0.3009 0.3843 0.1430 -0.2599 0.2605 0.
0.2269 -0.2256 0.0915 0.0993 0.2614 0.0851 -0.1673 0.3004 0.2567 -0.3666 0.
-0.4622 -0.4718 -0.2401 0.1017 -0.1647 -0.3149 -0.0399 0.1955 -0.3101 -0.0108 0.
0.3410 0.3215 -0.2513 -0.4240 -0.1692 -0.2803 -0.1779 -0.0533 0.2640 0.0929 0.
0.0187 -0.1220 -0.3447 -0.2770 0.1906 0.3073 0.1765 0.2978 0.1564 -0.1104 -0.
-0.2475 -0.1130 -0.0726 -0.3576 -0.2480 0.1056 0.2548 -0.2648 0.2326 0.0619 -0.
2
-0.1807 -0.1033 0.2124 -0.0195 -0.1946 -0.2834 0.2388 0.4874 0.5945 0.1137 0.
0.1015 -0.2277 0.1001 0.2713 0.1285 0.0630 -0.1961 -0.1119 0.2307 0.7904 -0.
-0.1470 -0.2603 -0.3955 -0.0522 0.2613 0.3783 0.0995 -0.2714 0.2238 0.0522 0.
0.3790 -0.2029 0.2402 0.0675 0.2298 -0.0247 0.4233 0.0516 -0.0790 -0.0429 0.
0.0591 -0.1771 -0.1705 0.1287 0.3456 -0.5824 -0.0532 -0.3927 0.2393 -0.2339 -0.
-0.2755 0.4657 -0.3417 0.4784 0.1073 -0.0145 -0.0502 0.0827 0.2438 -0.0776 -0.
-0.2056 0.4034 0.0619 0.0621 0.2493 -0.0148 0.4402 0.0812 -0.1043 0.1492 0.
-0.0052 -0.0631 -0.0398 -0.1532 -0.1841 -0.0520 -0.2331 0.0435 -0.0408 -0.0018 0.
Eigen_Values = zeros(NR,1);
for i=1:NR
Eigen_Values(i)=S(i,i);
end
disp("Non zero Entries is S Matrix")
disp(Eigen_Values)
45.6406
40.4238
30.4524
25.5607
22.0945
17.7481
14.6728
12.7182
%Q-7
x_new = V * x;
y_new = H * x_new;
y = U' * y_new;
ys = y/ Eigen_Values;
disp("Decoded Vector ys")
Decoded Vector ys
disp(ys)
0.0000 - 1.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 +
-0.6263 - 0.6263i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 +
-0.2553 + 0.6164i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 +
0.2143 - 0.5174i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 +
-0.4472 - 0.1853i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 +
0.3593 - 0.1488i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 +
-0.2970 + 0.1230i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 +
-0.1066 - 0.2574i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 +
nonzeros_x=x(1:NR);
disp("Nr non zero Element of X")
3
Nr non zero Element of X
disp(nonzeros_x)
-0.0000 - 1.0000i
-0.7071 - 0.7071i
-0.3827 + 0.9239i
0.3827 - 0.9239i
-0.9239 - 0.3827i
0.9239 - 0.3827i
-0.9239 + 0.3827i
-0.3827 - 0.9239i