Matlab 如何计算点之间的距离?

Matlab 如何计算点之间的距离?,matlab,Matlab,我想计算用户位置、接入点和基站之间的距离 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 =

我想计算用户位置、接入点和基站之间的距离

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')
使用

AP和用户之间:

pdist2([AccessPointX(:) AccessPointY(:)],[UserLocationX(:) UserLocationY(:)])

其他情况也类似。

用户与BS之间、BS与AP之间或用户与AP之间?用户与BS之间、用户与API之间更改了标题。如何编写Matlab代码相当广泛;图中未显示距离这是计算距离问题的答案。如果这不是你想要的,我建议重新措辞你的问题。