Plotting target points within an n radius plot

조회 수: 12 (최근 30일)
sree chak
sree chak 2020년 9월 4일
댓글: sree chak 2020년 9월 4일
I have created a detection range of 20 m radius and essentially created x,y,z points within that range randomly. What I want to be able to do is plot the detection circle, and then plot [detectionx, detectiony, guessz] as a point (maybe a red point) Similar to this (but without the blue points). Any help will be appreciated.
DetectionRange = 2*pi*(rand(1,1));
DetectionRadius = 20*sqrt(rand(1,1));
Detectionx = 20 + DetectionRadius.*cos(DetectionRange); %x coordinate of the dipole is randomly selected somewhere within the radius of 20.
Detectiony = 20 + DetectionRadius.*sin(DetectionRange); %y coordinate of the dipole is randomly selected somewhere within the radius of 20.
Guessz = 0;

채택된 답변

Akira Agata
Akira Agata 2020년 9월 4일
How about the following solution?
% Data points (N = 10, for example.)
numPoints = 10;
detRange = 2*pi*(rand(numPoints,1));
detRadius = 20*sqrt(rand(numPoints,1));
% Convert to cartesian coordinages
[detX, detY] = pol2cart(detRange,detRadius);
% Show the result
figure
rectangle(...
'Position', [-20 -20 40 40],...
'Curvature', [1 1],...
'EdgeColor', 'r')
hold on
scatter(detX,detY,'r^')
daspect([1 1 1])
grid on
box on
  댓글 수: 1
sree chak
sree chak 2020년 9월 4일
This is brilliant and just what I needed!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Vector Fields에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by