Create circle that has random "noisy" points along circumference within 10% of circle radius

3 views (last 30 days)
I need to create a circle of radius=20, centered at x=0, y=0. I then need to create random points along the circumference that may occur within +/-10% of the circles radius.
The image above is an example of what im trying to create.
Im fairly new to matlab, this is the code i have so far
%create circle
r=20; %mm
%// center
c = [0 0];
pos = [c-r 2*r 2*r];
rectangle('Position',pos,'Curvature',[1 1])
axis equal
And this is the code ive tried to make random points within +/-10% of a r=20 circle
x0=0; % x0 and y0 are center coordinates
y0=0;
r=20; % radius mm
angle=-pi:0.1:pi;
angl=angle(randi(numel(angle),150,1))
x=r*cos(angl)+x0
y=r*sin(angl)+y0
scatter(x,y)
xlim([-r-1 r+1]+x0)
ylim([-r-1 r+1]+y0)
axis square
Its close to what im trying to get but its just generating random points directly on the circumference i think.
Is there also a way I can make a seed for the random points along the circumference so that i can get comparable results?
I also need the "noise" points along the circumference to be asterisks, if thats possible. Any help or guidance would be greatly appreciated. I know this post is asking a lot, I'm just very confused and cant find any other question looking for the same or similar results.

Answers (1)

Matt J
Matt J on 4 Aug 2021
You can use this circularFit.xysim() from this FEX package
close all
[x0,y0]=deal(0,0); %Center coordinates
radius=20; %Circle radius
thetaSamps=linspace(0,360,120); %Sample angles in degrees
xy=circularFit.xysim([x0,y0], radius, thetaSamps, 0.1*radius); %Generate noisy samples
plot( circularFit(xy) );

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!