how to create 3 random numbers in a circle with 3 different radiuses.
Show older comments
I have to make 15 circles with each circle there are 3 random numbers that can will find in a 3 different radiuses??
4 Comments
Image Analyst
on 28 Jan 2017
I find this confusing.
Do you need 15 circles with 15 radii, or 3 circles with 3 different radii? Or does "15 circles with each circle" mean that there are 15 circles inside each of 3 other circles? Please attach a diagram.
And are these 15 or 3 circles in an image (2-D array) where the values are all 0 except for 3 pixels (locations) where the values are random numbers?
idan rahamim
on 29 Jan 2017
Walter Roberson
on 29 Jan 2017
Unfortunately I cannot tell from the picture whether there are different random maximum radius for each of the three strawberries, or if the maximum radius is the same for each of them.
My code can be used for both circumstances: if the maximum radius is the same for each of the three, then use a scalar for R, but if there are different maximum radius then use a vector of length 3 for the maximum radius R.
idan rahamim
on 29 Jan 2017
Edited: Image Analyst
on 30 Jan 2017
Accepted Answer
More Answers (2)
idan rahamim
on 3 Feb 2017
0 votes
9 Comments
Walter Roberson
on 4 Feb 2017
text(xoff(:), yoff(:), num2str([xoff(:), yoff(:)], 'HorizontalAlignment', 'center')
idan rahamim
on 4 Feb 2017
Edited: idan rahamim
on 4 Feb 2017
Walter Roberson
on 4 Feb 2017
text(X(:), Y(:), num2str([X(:), Y(:)], 'HorizontalAlignment', 'center')
idan rahamim
on 4 Feb 2017
Walter Roberson
on 4 Feb 2017
Edited: Walter Roberson
on 4 Feb 2017
berries_per_bush = 3; %given
bushRadius = 15 / 2; %from diagram
minRadius = 3; %I made this up
maxRadius = bushRadius * 1.1; %I made this up
X = [7.5 28.5 49.5 70.5 91.5 15.5 38.5 61.5 84.5 7.5 28.5 49.5 70.5 91.5 15.5 38.5 61.5 84.5]; %from diagram
Y = [84.5 * ones(1,5), 61.5 * ones(1,4), 38.5 * ones(1,5), 15.5 * ones(1,4)]; %from diagram
X = X(:); Y = Y(:);
nb = length(X);
rr = minRadius + (rand(nb,berries_per_bush)) .* (maxRadius - minRadius);
rt = rand(nb,berries_per_bush)* 2*pi;
[xoff, yoff] = pol2cart(rt, rr) ;
Cx = repmat(X,1,berries_per_bush) + xoff;
Cy = repmat(Y,1,berries_per_bush) + yoff;
scatter(Cx(:), Cy(:), 'ko', 'filled');
hold on
viscircles([X(:), Y(:)], bushRadius * ones(nb,1), 'LineWidth', 1, 'Color', 'k');
hold off
axis image
text(X(:), Y(:), num2str([X(:), Y(:)], '[%.1f %.1f]'), 'HorizontalAlignment', 'center')
If you want the coordinates outside of the bush like on the diagram, then you should decide where you want them to be placed and what you want them to say and text() the strings into place, and then use <https://www.mathworks.com/help/matlab/ref/annotation.html annotation()) to draw the lines pointing where you want them to point.
idan rahamim
on 5 Feb 2017
Walter Roberson
on 5 Feb 2017
The viscircles does that.
idan rahamim
on 6 Feb 2017
Walter Roberson
on 6 Feb 2017
You can remove the 'color', 'k' part of the viscircles call
idan rahamim
on 18 Feb 2017
0 votes
1 Comment
Walter Roberson
on 18 Feb 2017
Please start a new Question for that topic.
In that new topic, you should explain whether "long" is in terms of time or in terms of distance. If it is in terms of time, then you need to talk about rotational velocities and constraints -- for example if there are no constraints and everything can move at the same time, then the time requires would be equal to the maximum time to rotate on one of the axes, since all of the rotations could take place at the same time. Either way you would need to do motion planning, since in 3 or more degrees of freedom without constraints there are always multiple ways of reaching the same destination.
Categories
Find more on Animation 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!