How to plot circles around centre points?
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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)));
0 commentaires
Réponse acceptée
Image Analyst
le 30 Avr 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);
Plus de réponses (1)
Image Analyst
le 29 Avr 2015
Did you try plot?
plot(real(s),imag(s), 'bo', 'MarkerSize', 20, 'LineWidth', 2);
grid on;
Voir également
Catégories
En savoir plus sur Line Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!