Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
katarinavuckovic authored Jul 7, 2021
1 parent eca0788 commit 9d562e0
Show file tree
Hide file tree
Showing 7 changed files with 366 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Mixed Scenario/ADPPeaksUnique1.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
function [angles,delays,powers] = ADPPeaksUnique1(ADP,N)
angles = [];
delays = [];
powers = [];
Lm = imregionalmax((ADP));
[A B]= (find(Lm == 1));
for i = 1 : length(A)
Amp(i)=ADP(A(i),B(i));
end
Amp = sort(Amp,'descend');
M = 0;
i = 1;
while(M<N)
[a d] = find(ADP == Amp(i));
angles = [angles;a];
delays = [delays;d];
i=i+1;
M = length(unique(angles));

end
delays = delays;% * 3*10^8/(5*10^8);
len = length(angles);
powers = Amp(1:len);
end
Binary file added Mixed Scenario/BW1.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions Mixed Scenario/CSI2ADP_theta_NN.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function [ADP] = CSI2ADP_theta_NN(H,Ntt,Ncc,Nt,Nc)
%%
V = zeros(Nt,Ntt);
%theta = linspace(0,pi,Ntt);
for i = 1 : Nt
for j = 1 : Ntt
V(i,j) = exp(-1i * pi * (i) * cos(j*pi/Ntt));
end
end

% Constructing F
F = zeros(Nc,Ncc);
%theta = linspace(0,1,Ncc);
for i = 1 : Nc
for j = 1 : Ncc
F(i,j) = exp(1i * 2 * pi * i * j / Ncc );
end
end

ADP = V' * (H) * F ;
end
124 changes: 124 additions & 0 deletions Mixed Scenario/Reflection4pl.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
function [img,lines,pline]=Reflection4pl(img, thetaD ,power,delay)
p = power;
pline = []; %power of everyline
de = delay;
lines=[];
%convering Theta to radians
theta = degtorad(thetaD);
%these angles do not have reflection surface
cLOS = 'red'; %line of site color
c1R = 'blue'; % 1st reflection
c2R = 'yellow'; % 2nd reflection
noReflection = [8 9 10 157 158 159 160 170 171 0 180];
%Base station Location
x0 = 343;
y0 = 267;
plot(x0, y0, 'b*', 'LineWidth', 2, 'MarkerSize', 5);
t = strcat(num2str(x0),',',num2str(y0));
p1 = [y0,x0];
for i = 1: length (theta)
t1 = strcat(num2str(thetaD(i)),', ', num2str(p(i),'%.2f'),', ',num2str(de(i),'%.2f'))
if (ismember(thetaD(i), thetaD(1:(i-1)))==0)
if(thetaD(i)<30)
%Incident Wave
d = 270;
xi = x0-d;
yi = y0-d*tan(theta(i));
p2 = [yi,xi];
plot([p1(2),p2(2)],[p1(1),p2(1)],'Color',cLOS,'LineWidth',1);
newline = [p1,p2];
lines = [lines;newline];
pline = [pline;p(i)];
%reflected
if ~ismember(thetaD(i), noReflection)
xr = xi+abs(yi-177)/tan(theta(i));
yr = 177;
p3 = [yr, xr];
plot([p2(2),p3(2)],[p2(1),p3(1)],'Color',c1R,'LineWidth',1);
newline = [p2,p3];
lines = [lines;newline];
pline = [pline;p(i)];
%display angle
t = strcat(num2str(thetaD(i)));
% text(p2(2)-25,p2(1),t,'Color','r','FontSize',8);
if ismember(thetaD(i),[12,13])
%2nd reflected wave
xr2 = xr+abs(yi-177)/tan(theta(i));
yr2 = yi;
p4 = [yr2, xr2];
plot([p3(2),p4(2)],[p3(1),p4(1)],'Color',c2R,'LineWidth',1);
newline = [p3,p4];
lines = [lines;newline];
pline = [pline;p(i)];
end

end
elseif(thetaD(i)<=147)
%Incident Wave
d = 90;
xi = x0-d./tan(theta(i));
yi = y0-d;
p2 = [yi,xi];
plot([p1(2),p2(2)],[p1(1),p2(1)],'Color',cLOS,'LineWidth',1);
newline = [p1,p2];
lines = [lines;newline];
pline = [pline;p(i)];
if ~ismember(thetaD(i), noReflection)
%Reflected Wave
xr = xi-d./tan(theta(i));
yr = 275;
p3 = [yr, xr];
plot([p2(2),p3(2)],[p2(1),p3(1)],'Color',c1R,'LineWidth',1);
newline = [p2,p3];
lines = [lines;newline];
pline = [pline;p(i)];
%display angle
%2nd Reflected Wave
if((thetaD(i)>44&&thetaD(i)<66)||(thetaD(i)>79&&thetaD(i)<106)||(thetaD(i)>118&&thetaD(i)<138))
%ranges for the angles are determined experimentally by trial and
%error and are specific the figure
d = 90;% determined experimentally and only valid for BW1.
xr2 = xr-d./tan(theta(i));
yr2 = yi; %determined experimentally
p4 = [yr2, xr2];
plot([p3(2),p4(2)],[p3(1),p4(1)],'Color',c2R,'LineWidth',1);
newline = [p3,p4];
lines = [lines;newline];
pline = [pline;p(i)];
%display angle
end
end
t = strcat(num2str(thetaD(i)));
% text(p2(2),p2(1)-15,t,'Color','r','FontSize',8);

else
%Incident Wave
theta(i) = 2*pi() - theta(i);
d = 285;
xi = x0+d;
yi = y0-d*tan(theta(i));
p2 = [yi,xi];
plot([p1(2),p2(2)],[p1(1),p2(1)],'Color',cLOS,'LineWidth',1);
newline = [p1,p2];
lines = [lines;newline];
pline = [pline;p(i)];
if ~ismember(thetaD(i), noReflection)
xr = xi-abs(yi-177)/tan(theta(i));
yr = 177;
p3 = [yr, xr];
plot([p2(2),p3(2)],[p2(1),p3(1)],'Color',c1R,'LineWidth',1);
newline = [p2,p3];
lines = [lines;newline];
pline = [pline;p(i)];
%display angle
t = strcat(num2str(thetaD(i)));
% text(p2(2)-15,p2(1),t,'Color','r','FontSize',8);
end
%display angle
t = strcat(num2str(thetaD(i)));
% text(p2(2),p2(1),t,'Color','r','FontSize',8);
end
end
end
end

155 changes: 155 additions & 0 deletions Mixed Scenario/bus_reflection2.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
function [img,lines] = bus_reflection2(img,thetaD)
lines = [];
%base station position
x0 = 343;
y0 = 267;
p1 = [y0,x0];
%convering Theta to radians
theta = degtorad(thetaD);
c1R= 'b';
c2R = 'yellow';
for i = 1: length (theta)
%Calculating Incident and Reflected points

t1 = strcat(num2str(thetaD(i)));%
%ploting the incident and reflected waves
if (ismember(thetaD(i), thetaD(1:(i-1)))==0)
if(thetaD(i)>=24 && thetaD(i)<=75)
%Bottom Bus L
%Incident Wave
d = 32;
xi = x0-d./tan(theta(i));
yi = y0-d;
%Reflected Wave
d = 40;
xr = xi-d./tan(theta(i));
yr = yi+d;
% %incident wave
p2 = [yi,xi];
%reflected wave
p3 = [yr, xr];
plot([p2(2),p3(2)],[p2(1),p3(1)],'Color',c1R,'LineWidth',1);
newline = [p2,p3];
lines = [lines;newline];
%Reflected Wave (2nd reflection)
if(thetaD(i)<=40 || thetaD(i)>=65)
d = 90;
xr2= xr-d./tan(theta(i));
yr2 = yr-d;
p4 = [yr2, xr2];
plot([p3(2),p4(2)],[p3(1),p4(1)],'Color',c2R,'LineWidth',1);
newline = [p3,p4];
lines = [lines;newline];
%display angle
t = strcat(num2str(thetaD(i)));
end
end
if(thetaD(i)>=75 && thetaD(i)<=80)
%R side Bus L
% %Incident Wave
d = 8;
xi = x0-d;
yi = y0-d*tan(theta(i));
p2 = [yi,xi];
% plot([p1(2),p2(2)],[p1(1),p2(1)],'Color',ray_color,'LineWidth',1);
%reflected wave
xr = xi + abs(yi-177)/tan(theta(i));
yr = 177;
p3 = [yr, xr];
plot([p2(2),p3(2)],[p2(1),p3(1)],'Color',c1R,'LineWidth',1);
newline = [p2,p3];
lines = [lines;newline];
% 2nd reflected wave
xr2 = xr + abs(yi-177)/tan(theta(i));
yr2 = yi;
p4 = [yr2, xr2];
plot([p3(2),p4(2)],[p3(1),p4(1)],'Color',c2R,'LineWidth',1);
newline = [p3,p4];
lines = [lines;newline];
%display angle
t = strcat(num2str(thetaD(i)));
% text(p2(2)-25,p2(1),t,'Color','b','FontSize',8);
end
if(thetaD(i)>=154 && thetaD(i)<160)
%L side bus R
% %Incident Wave
d = 87;
xi = x0+d;
yi = y0+d*tan(theta(i));
p2 = [yi,xi];
% plot([p1(2),p2(2)],[p1(1),p2(1)],'Color','r','LineWidth',1);
%Reflected Wave
theta(i) = 2*pi() - theta(i);
xr = xi - abs(yi-177)/tan(theta(i));
yr = 177;
p3 = [yr, xr];
plot([p2(2),p3(2)],[p2(1),p3(1)],'Color',c1R,'LineWidth',1);
newline = [p2,p3];
lines = [lines;newline];
%2nd Reflected Wave
xr2 = xr - abs(yi-177)/tan(theta(i));
yr2 = yi;
p4 = [yr2, xr2];
plot([p3(2),p4(2)],[p3(1),p4(1)],'Color',c2R,'LineWidth',1);
newline = [p3,p4];
lines = [lines;newline];
%display angle
t = strcat(num2str(thetaD(i)));
% text(p2(2),p2(1),t,'Color','b','FontSize',8);
end
if(thetaD(i)>160 && thetaD(i)<168)
%Bottom Bus R
%Incident Wave
d = 32;
xi = x0-d./tan(theta(i));
yi = y0-d;
%Reflected Wave
d = 40;
xr = xi-d./tan(theta(i));
yr = y0;
% %incident wave
p2 = [yi,xi];
% plot([p1(2),p2(2)],[p1(1),p2(1)],'Color',ray_color,'LineWidth',1);
%reflected wave
p3 = [yr, xr];
plot([p2(2),p3(2)],[p2(1),p3(1)],'Color',c1R,'LineWidth',1);
newline = [p2,p3];
lines = [lines;newline];
end
if((thetaD(i)>63 && thetaD(i)<90)||(thetaD(i)>124 && thetaD(i)<138))
%Top L bus and Top R bus
%Incident Wave
d = 90;
xi = x0-d./tan(theta(i));
yi = y0-d;
%Reflected Wave
d=42;
xr = xi-d./tan(theta(i));
yr = y0-d;
%2ns Reflected Wave
xr2 = xr-d./tan(theta(i));
yr2 = yr-d;
%incident wave
p2 = [yi,xi];
% plot([p1(2),p2(2)],[p1(1),p2(1)],'Color',ray_color,'LineWidth',1);
%reflected wave
p3 = [yr, xr];
plot([p2(2),p3(2)],[p2(1),p3(1)],'Color',c1R,'LineWidth',1);
newline = [p2,p3];
lines = [lines;newline];
% 2nd reflection
p4 = [yr2, xr2];
plot([p3(2),p4(2)],[p3(1),p4(1)],'Color',c2R,'LineWidth',1);
newline = [p3,p4];
lines = [lines;newline];
%display angle
t = strcat(num2str(thetaD(i)));
% text(p2(2),p2(1),t,'Color','b','FontSize',8);
end
%
%
end

end
end

18 changes: 18 additions & 0 deletions Mixed Scenario/kmeans_silhouette.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function [k,smean] = kmeans_silhouette(X,kmax)
%UNTITLED5 Summary of this function goes here
% This function finds the optimal k using silhouette method
%Input:
% X - data in Nx2 formal [xi,yi];
% kmax = largest k value to consider
%Output:
% k - optimal k
% smean - is the S-score for each k value
size = length(X);
KMAX = min(size, kmax);
for i = 2:KMAX
clust = kmeans(X,i,'distance','sqeuclidean','emptyaction','drop');
s = silhouette(X,clust,'Euclidean');
smean(i) = mean(s);
end
[smax k] = max(smean);
end
24 changes: 24 additions & 0 deletions Mixed Scenario/show_bus.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
function [img] = show_bus(img)
color = 'black';
linewidth = 1;
%bus 1
p1 = [275 235];
p2 = [335 235];
p3 = [335 225];
p4 = [275 225];
plot([p1(1),p2(1)],[p1(2),p2(2)],'Color',color,'LineWidth',linewidth);
plot([p1(1),p4(1)],[p1(2),p4(2)],'Color',color,'LineWidth',linewidth);
plot([p3(1),p2(1)],[p3(2),p2(2)],'Color',color,'LineWidth',linewidth);
plot([p3(1),p4(1)],[p3(2),p4(2)],'Color',color,'LineWidth',linewidth);
%bus 2
p1 = [430 235];
p2 = [490 235];
p3 = [490 225];
p4 = [430 225];
plot([p1(1),p2(1)],[p1(2),p2(2)],'Color',color,'LineWidth',linewidth);
plot([p1(1),p4(1)],[p1(2),p4(2)],'Color',color,'LineWidth',linewidth);
plot([p3(1),p2(1)],[p3(2),p2(2)],'Color',color,'LineWidth',linewidth);
plot([p3(1),p4(1)],[p3(2),p4(2)],'Color',color,'LineWidth',linewidth);

end

0 comments on commit 9d562e0

Please sign in to comment.