Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

EXP 1 Modeling of wireless communication systems using Matlab(Two ray channel and Okumura

–Hata model)

PROGRAM:

frequency=960e6;
transmitterHeigtht=50;
receiverheight=10;
distance=100:100:1000;
%Two ray channel model
pt=1;
gt=1;
gr=1;
l=1;
%calculate received power using Two ray channel model
pr_two_ray=pt*(gt*gr*(transmitterHeigtht*receiverheight)^2./distance.^4*l);
%okumura-hata model
a=69.55;
b=26.16;
c=13.82;
d=44.9;
x=6.55;
bb=30;
%calculate path oss using okumura_hata model
pl_okumura_hat=a+b*log10(distance)+c*log10(frequency/1e6)+d-x*log10(bb);
%ploting
figure;
plot(distance,pr_two_ray,'b-','LineWidth',2);
hold on;
plot(distance,pl_okumura_hat,'r--','LineWidth',2);
xlabel('distance(m)');
ylabel('Received power path loss(dB)');
legend('Tworay channel model','Okumura-hata model');
title('wireless communication system modeling');
grid on;
EXP 2 Modeling and simulation of Multipath fading channel

PROGRAM:

numSamples = 1000;
numPaths = 3;
fadePower = 0.5;
h = sqrt(fadePower/2)*(randn(numPaths, numSamples) + 1i*randn(numPaths,
numSamples));
txSignal = randn(1, numSamples) + 1i*randn(1, numSamples);
rxSignal = zeros(1, numSamples);
for path = 1:numPaths
rxSignal = rxSignal + h(path, :) .* txSignal;
end

t = 1:numSamples;
figure; subplot(2,1,1);
plot(t, real(txSignal), 'b', t, imag(txSignal), 'r');
title('Transmitted Signal');
legend('In-phase', 'Quadrature');
xlabel('Time');
ylabel('Amplitude');
subplot(2,1,2);
plot(t, real(rxSignal), 'b', t, imag(rxSignal), 'g');
title('Received Signal');
legend('In-phase', 'Quadrature');
xlabel('Time');
ylabel('Amplitude');

EXP 3 Modulation: Spread Spectrum – DSSS Modulation & Demodulation

PROGRAM:

clc;
b=[1 0 1 0 1 0 1 0];
ln=length(b);
for i=1:ln
if b(i)==0
b(i)=-1;
end
end
k=1;
for i=1:ln
for j=1:8
bb(k)=b(i);
j=j+1;
k=k+1;
end
i=i+1;
end
len=length(bb);
subplot(2,1,1);
stairs(bb);%stairs(bb,'lineiwdth',2);
axis([0 len -2 3]);
title('ORIGINAL BIT SEQUENCE b(t)');
pr_sig=round(rand(1,len));
for i=1:len
if pr_sig(i)==0
pr_sig(i)=-1;
end
end
subplot(2,1,2);
stairs(pr_sig);%stairs(pr_sig,'linewidth',2);
axis([0 len -2 3]);
title('PSEUDORANDOM BIT SEQUENCE pr_sig(t)');
for i=1:len
bbs(i)=bb(i).*pr_sig(i);
end
dsss=[];
t=0:1/10:2*pi;
c1=cos(t);
c2=cos(t+pi);
for k=1:len
if bbs(1,k)==-1
dsss=[dsss c1];
else
dsss=[dsss c2];
end
end
figure,
subplot(2,1,1);
stairs(bbs);%strairs(bbs,'linewidth',2);
% axis([0 len -2 3]);
title('MULTIPLIER OUTPUT SEQUENCE b(t)*pr_sig(t)');
subplot(2,1,2);
plot(dsss);
title(' DS-SS SIGNAL...');
EXP 4

1.BIT ERROR RATE(BER)

PROGRAM:

clc;
num_bits=10000;
snr_dB=0:2:20;
data=randi([0,1],1,num_bits);
modulated_data=2*data-1;
ber_simulated=zeros(size(snr_dB));
ber_theoritical=zeros(size(snr_dB));
for i=1:length(snr_dB)
snr_linear=10^(snr_dB(i)/10);
noise_std=sqrt(1/(2*snr_linear));
noise=noise_std*randn(1,num_bits);
received_signal=modulated_data+noise;
demodulated_data=sign(received_signal);
num_error=sum(demodulated_data~=data);
ber_simulated(i)=num_error/num_bits;
ber_theoritical(i)=0.5*erfc(sqrt(snr_linear));
end
figure;
semilogy(snr_dB,ber_simulated,'ro-','LineWidth',2,'MarkerSize',10);
hold on;
semilogy(snr_dB,ber_theoritical,'b^-','LineWidth',2,'MarkerSize',8);
hold off;
grid on;
legend('Simulated BER','Theoritical BER');
xlabel('SNR(dB)');
ylabel('Bit error rate(BER)');
title('Bit ErroR Rate(BER) for BPSK Modulation in AWGN Channel');
2. PACKET ERROR RATE(PER)

PROGRAM:

clc;
num_packets=1000;
packet_length=100;
snr_dB=10;
snr_linear = 10^(snr_dB / 10);
noise_std = sqrt(1 / (2 * snr_linear));
num_errors = 0;
for i = 1:num_packets
packet_data = randi([0, 1], 1, packet_length);
modulated_data = 2 * packet_data - 1;
noise = noise_std * randn(1, packet_length);
received_signal = modulated_data + noise;
demodulated_data = sign(received_signal);
if any(demodulated_data ~= packet_data)
num_errors = num_errors + 1;
end
end
perr = num_errors / num_packets;
disp(['Number of packets: ' num2str(num_packets)]);
disp(['Packet length: ' num2str(packet_length)]);
disp(['SNR (dB): ' num2str(snr_dB)]);
disp(['Simulated Packet Error Rate (PER): ' num2str(perr)]);
figure;
for i = 1:min(num_packets, 5)
subplot(5, 1, i);
t = 1:packet_length;
plot(t, real(received_signal), 'b', t, imag(received_signal), 'r');
title(['Received Signal for Packet ' num2str(i)]);
xlabel('Time');
ylabel('Amplitude');
legend('I-channel', 'Q-channel');
end
3. BLOCK ERROR RATE(BLER)

PROGRAM:

clc;
num_blocks=50;
block_length=10;
snr_dB=10;
snr_linear=10^(snr_dB/10);
noise_std=sqrt(1/(2*snr_linear));
num_errors=0;
block_error_vector=zeros(1,num_blocks);
for i=1:num_blocks
block_data=randi([0,1],1,block_length);
modulated_data=2*block_data-1;
noise=noise_std*randn(1,block_length);
received_signal=modulated_data+noise;
demodulated_data=sign(received_signal);
if any(demodulated_data~=block_data)
num_errors=num_errors+1;
block_error_vector(i)=1;
end
end
bler=num_errors/num_blocks;
disp(['Number of blocks:',num2str(num_blocks)]);
disp(['Block length:',num2str(block_length)]);
disp(['SNR(dB):',num2str(snr_dB)]);
disp(['Simulated Block Error Rate(BLER):',num2str(bler)]);
figure;
stem(block_error_vector,'r','LineWidth',4);
title('Block Error Vector');
xlabel('Block Index');
ylabel('Block Error');
axis([0 num_blocks+1 -0.5 1.5]);

OUTPUT
Number of blocks:50
Block length:10
SNR(dB):10
Simulated Block Error Rate(BLER):1
4. ADJACENT CHANNEL LEAKAGE RATIO(ACLR)

PROGRAM:

clc;
fs=30.72e6;
t=0:1/fs:1;
freq_4g=2.5e6;
freq_5g=3.5e6;
signal_4g=cos(2*pi*freq_4g*t);
signal_5g=cos(2*pi*freq_5g*t);
[Pxx_4g,f_4g]=pwelch(signal_4g,[],[],[],fs);
[Pxx_5g,f_5g]=pwelch(signal_5g,[],[],[],fs);
center_freq_4g=freq_4g;
adjacent_freq_4g=freq_4g+5e6;
index_center_4g=find(f_4g==center_freq_4g);
index_adjacent_4g=find(f_4g==adjacent_freq_4g);
aclr_4g=10*log10(Pxx_4g(index_adjacent_4g)/Pxx_4g(index_center_4g));
center_freq_5g=freq_5g;
adjacent_freq_5g=freq_5g+5e6;
index_center_5g=find(f_5g==center_freq_5g);
index_adjacent_5g=find(f_5g==adjacent_freq_5g);
aclr_5g=10*log10(Pxx_5g(index_adjacent_5g)/Pxx_5g(index_center_5g));
disp(['4G ACLR:',num2str(aclr_4g),'dB']);
disp(['5G ACLR:',num2str(aclr_5g),'dB']);
figure;
%subplot(2,1,1);
semilogy(f_4g,Pxx_4g);
title('4g Signal Power Spectrum');
xlabel('Frequency(Hz)');
ylabel('Power/Frequency(dB/Hz)');
grid on;
figure;
%subplot(2,1,2);
semilogy(f_5g,Pxx_5g);
title('5g Signal Power Spectrum');
xlabel('Frequency(Hz)');
ylabel('Power/Frequency(dB/Hz)');
grid on;

You might also like