How to plot circles around centre points?

17 Ansichten (letzte 30 Tage)
ajk1
ajk1 am 29 Apr. 2015
Kommentiert: ajk1 am 30 Apr. 2015
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)));

Akzeptierte Antwort

Image Analyst
Image Analyst am 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);

Weitere Antworten (1)

Image Analyst
Image Analyst am 29 Apr. 2015
Did you try plot?
plot(real(s),imag(s), 'bo', 'MarkerSize', 20, 'LineWidth', 2);
grid on;
  1 Kommentar
ajk1
ajk1 am 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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Graphics Performance finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by