hello i want to ask a question how to make a circle in matlab and mark its center and g
Here's another option:
%// Set parameters
R = 0.5; %// radius
C = [3 4]; %// center [x y]
N = 50; %// number of points inside circle
%// generate circle boundary
t = linspace(0, 2*pi, 100);
x = R*cos(t) + C(1);
y = R*sin(t) + C(2);
%// generate random points inside it
th = 2*pi*rand(N,1);
r = R*rand(N,1);
xR = r.*cos(th) + C(1);
yR = r.*sin(th) + C(2);
%// Plot everything
figure(1), clf, hold on
plot(x,y,'b')
plot(C(1),C(2),'r.', 'MarkerSize', 100)
plot(xR,yR,'k.')
axis equal
Here's why that could be useful:
%// Set parameters
R = 0.5; N = 50;
C = [3 4]; M = 100; %// points on boundary
%// generate all points at once
t = linspace(0, 2*pi, M)';
th = 2*pi*rand(N,1);
r = R*rand(N,1);
xR = [R*ones(M,1); r] .* cos([t; th]) + C(1);
yR = [R*ones(M,1); r] .* sin([t; th]) + C(2);
%// Plot everything
figure(1), clf, hold on
plot(xR(1:M),yR(1:M),'b') %// circle boundary
plot(C(1),C(2),'r.', 'MarkerSize', 100) %// center
plot(xR(M+1:end),yR(M+1:end),'k.') %// random points
axis equal