ac lab
Constellation diagram
clc;close all;
clear;
m=16;
k=log2(m);
n=3000;
sps=1;
dataIn=randi([0 1],n,1);
dataInMatrix=reshape(dataIn,length(dataIn)/k,k);
dataSymbolsIn=bi2de(dataInMatrix);
dataMod=qammod(dataSymbolsIn,m,'bin');
dataModG=qammod(dataSymbolsIn,m);
% awgn
EbNo=10;
snr=EbNo+10*log10(k)-10*log10(sps);
receivedSignal= awgn(dataMod,snr,'measured');
receivedSignalG= awgn(dataModG,snr,'measured');
sPlotFig=scatterplot(receivedSignal,1,0,'g.');
hold on;
scatterplot(dataMod,1,0,k*primesPlotFig);
EYE DIAGRAM
clc;
clear;
close all;
N=800;
fs=5;
randn('state', 0);
am=2*(rand(1,N)>0.5)-1;
sincNum=sin(pi*(-fs:1/fs:fs));
sincDen=(pi*(-fs:1/fs:fs));
sincDenZero = find(abs(sincDen) < 10^-10);
sinc0p= sincNum./sincDen;
sinc0p(sincDenZero)=1;
% raised cosine filter
alpha = 0.5;
cosNum = cos(alpha*pi*(-fs:1/fs:fs));
cosDen = (1-(2*alpha*(-fs: 1/fs:fs)).^2);
cosDenZero=find(abs(cosDen)<10^-10);
cos0p=cosNum./cosDen;
cos0p(cosDenZero)=pi/4;
gt_alpha5=sinc0p.*cos0p;
amUpSampled=[am; zeros(fs-1,length(am))];
amU=amUpSampled(:); % filtered sequence
st_alpha5 = conv (amU,gt_alpha5); % taking only the first 4000 samples
st_alpha5=st_alpha5(1:4000);
st_alpha5_reshape = reshape (st_alpha5, fs*2, N*fs/10);
% close all
plot(0:1/fs:1.99,real(st_alpha5_reshape), 'g');
title('eye diagram with alpha=1.0');
xlabel('time')
ylabel('amplitude');
axis padded;
grid on;
ASK
clc;
clear;
close all;
f1=25;
f2=5;
a=3;
t=0:0.0001:1;
x=square(2*pi*f2*t)+1;
u=sin(2*pi*f1*t);
y=x.*u;
d=y./u;
subplot(4,1,1);
plot(t,x);
title('msg signal');
xlabel('time');
ylabel('amplitude');
grid on;
subplot(4,1,2);
plot(t,u);
title('carrier signal');
xlabel('time');
ylabel('amplitude');
grid on;
subplot(4,1,3);
plot(t,y);
title('modulated signal');
xlabel('time');
ylabel('amplitude');
grid on;
subplot(4,1,4);
plot(t,d);
title('demodulated signal');
xlabel('time');
ylabel('amplitude');
grid on;
FSK
clc;
clear;
close all;
f1=100;
f2=40;
f3=5;
t=0:0.001:1;
m=square(2*pi*f3*t);
c1=sin(2*pi*f1*t);
c2=sin(2*pi*f2*t);
for i=0:1000
if(m(i+1)==1)
s(i+1)=c1(i+1);
else
s(i+1)=c2(i+1);
end
end
for i=0:1000
if(s(i+1)==c1(i+1))
d(i+1)=1;
else
d(i+1)=0;
end
end
subplot(4,1,1)
plot(t,m);
title('message signal'); xlabel('time'); ylabel('amplitude');
subplot(4,1,2)
plot(t,c1);
title('carrrier 1'); xlabel('time'); ylabel('amplitude');
subplot(4,1,3)
plot(t,c2);
title('carrier 2'); xlabel('time'); ylabel('amplitude');
subplot(4,1,4)
plot(t,s);
title('modulated signal'); xlabel('time'); ylabel('amplitude');
figure;
plot(t,d);
axis padded;
title('message signal'); xlabel('time'); ylabel('amplitude');
BPSK
clc;
clear;
close all;
f1=25;
f2=5;
t=0:0.001:1;
m=(square(2*pi*f2*t)+1)/2;
c1=sin(2*pi*f1*t);
for i=0:1000
if(m(i+1)==1)
s(i+1)=c1(i+1)
else
s(i+1)=-c1(i+1)
end
end
for i=0:1000
if(s(i+1)==c1(i+1))
d(i+1)=1;
else
d(i+1)=0;
end
end
subplot(3,1,1)
plot(t,m);
title('message signal'); xlabel('time'); ylabel('amplitude');
subplot(3,1,2)
plot(t,c1);
title('message signal'); xlabel('time'); ylabel('amplitude');
subplot(3,1,3)
plot(t,s);
grid;
title('message signal'); xlabel('time'); ylabel('amplitude');
figure;
plot(t,d);
axis padded;
title('message signal'); xlabel('time'); ylabel('amplitude');
STRIP ANTENNA
clc;
close all;
clear
f=2.45e9;
c=3.8e8;
lambda=c/f;
LI=lambda/2;
h=patchMicrostrip('Length',75e-3,'Width',37e-3,'GroundPlaneLength',120e-3,'GroundPlaneWidth',120e-3);
show(h);
figure,pattern(h,f);
figure,patternElevation(h,f);
figure,patternAzimuth(h,f);
figure,pattern (h, 2e9, 0, 1:1:360);
figure,beamwidth(h,f,0,1:1:360);
figure, impedance (h,500e6:30e6:2.45e9);