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

6 次查看(过去 30 天)
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 个评论

请先登录,再进行评论。

回答(1 个)

KSSV
KSSV 2019-2-7
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 个评论

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by