could anyone help me to measure the distance between base station and users with respect to the following code.

1 view (last 30 days)
code:
user=[6];
for t = 1:length(user)
Xmax=1;
Ymax=1;
radius=2;
xsd=ones(1,user(t))*Xmax;
ysd=ones(1,user(t))*Ymax;
rrx=radius*sqrt(rand(1,N_UE(t)));
thetarx=2*pi*rand(1,N_UE(t));
xrx=xsd+rrx.*cos(thetarx);
yrx=ysd+rrx.*sin(thetarx);
th = 0:pi/100:2*pi;
xunit = radius * cos(th) + Xmax;
yunit = radius * sin(th) + Ymax;
figure
plot(xunit, yunit);
hold on
plot(ysd,xsd,'r^')
hold on
plot(yrx,xrx,'ko')
hold on
The code executes and gives me the figure.
With respect to the figure i need to measure the distance between all users with respect to the base station.
Could anyone please help me how to measure it.
  3 Comments

Sign in to comment.

Answers (1)

KSSV
KSSV on 7 Feb 2019
user=6;
d1 = zeros(user,1) ;
d2 = zeros(user,1) ;
for t = 1:length(user)
Xmax=1;
Ymax=1;
radius=2;
xsd=ones(1,user(t))*Xmax;
ysd=ones(1,user(t))*Ymax;
rrx=radius*sqrt(rand(1,N_UE(t)));
thetarx=2*pi*rand(1,N_UE(t));
xrx=xsd+rrx.*cos(thetarx);
yrx=ysd+rrx.*sin(thetarx);
th = 0:pi/100:2*pi;
xunit = radius * cos(th) + Xmax;
yunit = radius * sin(th) + Ymax;
figure
plot(xunit, yunit);
hold on
plot(ysd,xsd,'r^')
hold on
plot(yrx,xrx,'ko')
hold on
d1(t) = sqrt((xunit-xsd)^2+(yunit-ysd)^2) ;
d2(t) = sqrt((xunit-xrx)^2+(yunit-yrx)^2) ;
end
  9 Comments
Walter Roberson
Walter Roberson on 8 Feb 2019
https://www.mathworks.com/matlabcentral/fileexchange/24093-cprintf-display-formatted-colored-text-in-the-command-window

Sign in to comment.

Categories

Find more on Bioinformatics Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!