How to plot circles around centre points?

13 views (last 30 days)
Hi, I woild like help with my plot. Each point p2...p9 (with p7 omitted) are cetnre points of circles of radius 250 and I would like to know how to include the circle in this plot to show their edges.
p1=zeros(1,1);
p2= 1i*500;
p3= 2i*500;
p4= p1+500*(cosd(30)+(1i*sind(30)));
p5= p2+500*(cosd(30)+(1i*sind(30)));
p6= p3+500*(cosd(30)+(1i*sind(30)));
p8= p5+500*(cosd(30)-(1i*sind(30)));
p9= p6+500*(cosd(30)-(1i*sind(30)));
s=[p2,p3,p4,p5,p6,p8,p9];
figure, scatter(real(s),imag(s));grid;
Also in p5 I have some random points within the circle radius (that may also exceed the radius) and I would also like to know how to add these on the plot
U_rad=rand(100,1)*(289-35)+35;
U=rand(100,1)*360;
U_pos=(p5+U_rad.*(cosd(U)+1i*sind(U)));

Accepted Answer

Image Analyst
Image Analyst on 30 Apr 2015
ajk1, try this:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear all;
workspace; % Make sure the workspace panel is showing.
format short g;
format compact;
fontSize = 20;
p1=zeros(1,1);
p2= 1i*500;
p3= 2i*500;
p4= p1+500*(cosd(30)+(1i*sind(30)));
p5= p2+500*(cosd(30)+(1i*sind(30)));
p6= p3+500*(cosd(30)+(1i*sind(30)));
p8= p5+500*(cosd(30)-(1i*sind(30)));
p9= p6+500*(cosd(30)-(1i*sind(30)));
s=[p2,p3,p4,p5,p6,p8,p9];
x = real(s);
y = imag(s);
theta = 0 : 0.01 : 2*pi;
radius = 125;
% Plot all the circles with a radius of 125
for k = 1 : length(x)
xCenter = x(k);
yCenter = y(k);
thisX = radius * cos(theta) + xCenter;
thisY = radius * sin(theta) + yCenter;
% Plot cross hairs at center
plot(xCenter, yCenter, 'r+', 'MarkerSize', 15, 'LineWidth', 2);
hold on;
% Plot circles around the center
plot(thisX, thisY, 'b-', 'LineWidth', 2);
fprintf('Plotted circle #%d at (%.1f, %.1f)\n', k, xCenter, yCenter);
end
axis equal;
% xlim([0 20]);
% ylim([0 20]);
grid on;
xlim([min(x)-radius, max(x)+radius]);
ylim([min(x)-radius, max(y)+radius]);
xlabel('X', 'FontSize', fontSize);
ylabel('Y', 'FontSize', fontSize);

More Answers (1)

Image Analyst
Image Analyst on 29 Apr 2015
Did you try plot?
plot(real(s),imag(s), 'bo', 'MarkerSize', 20, 'LineWidth', 2);
grid on;
  1 Comment
ajk1
ajk1 on 29 Apr 2015
Hi thanks for your comment, ideally I would like to keep the centre point as I need to show this position and around this centre point I need to plot a circle of radius 250 (meters). Then using the code for generating points (U_pos) I would like to know how to plot these points inside the area of the central circle (ps) on one graph. So it's basically an attempt of plotting multiple items on the graph that overlap but I'm not sure how to do it. I have tried but failed. Thanks.

Sign in to comment.

Categories

Find more on Graphics Performance in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!