2013-12-10 216 views
-3

我想计算出用户的位置,接入点和基站如何计算点之间的距离?

figure('Color', 'white') 
UserLocationX = randi(50, 1, 50); 
UserLocationY = randi(50, 1, 50); 
plot(UserLocationX, UserLocationY, '^-', 'MarkerSize', 5, 'LineWidth', 2), hold on  
AccessPointX = randi(50, 1, 8); 
AccessPointY = randi(50, 1, 8); 
plot(AccessPointX, AccessPointY, 'go', 'MarkerSize', 5, 'LineWidth', 6), hold on 
BaseStationX = 25; 
BaseStationY = 25; 
plot(BaseStationX, BaseStationY, 'rs', 'MarkerSize', 5, 'LineWidth', 6), hold on, grid on 
leg = legend('User Location', 'Access Point', 'Base Station'); 
set(leg, 'Location', 'NorthEastOutside') 
xlabel('x-candidate') 
ylabel('y-candidate') 
title('Scenario') 
+0

在用户与基站之间,基站与基站之间,还是用户与基站之间? –

+0

用户和BS之间,用户和AP之间 – user3087700

+3

我改变了标题。 “如何编写Matlab代码”相当广泛;) – thewaywewalk

回答

0

使用pdist2之间的距离。

AP和用户之间:

​​

其他情况是相似的。

+1

距离没有显示在图 – user3087700

+0

这是你的问题的答案(“计算距离”)。如果这不是你想要的,我建议改写你的问题。 – Daniel