how to initialize distance between two users

조회 수: 3 (최근 30일)
ANUSAYA SWAIN
ANUSAYA SWAIN 2023년 5월 16일
답변: Walter Roberson 2023년 5월 16일
Suppose i have two users. i want to set the distance between them as 1 m.

답변 (1개)

Walter Roberson
Walter Roberson 2023년 5월 16일
xy0 = randi(100, 1, 2) %cm, 10 m
xy0 = 1×2
40 43
radius = 10; %cm, 1 m
rand_angle = rand(1,1) * 2*pi;
[dx, dy] = pol2cart(rand_angle, radius);
xy1 = xy0 + [dx, dy]
xy1 = 1×2
48.7295 47.8781
plot(xy0(1), xy0(2), 'k.', xy1(1), xy1(2), 'b*');
xlim([0 100]); ylim([0 100]);
legend({'original point', 'point 1 m away'});
xlabel('cm'); ylabel('cm')

카테고리

Help CenterFile Exchange에서 Elementary Math에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by