Using viscircles to draw circles around points.

28 次查看(过去 30 天)
Hello, I am trying to draw to circles using viscircles but some of the circles end up in random space instead of around the center coordiantes ive given them. Below is the code I am using to draw my circles and a picture of what is happening on the plot. Any help would be greatly appreciated
% draw exlcusion range circles b/w hormone seeds and hormone seeds
HS_kept_x = HS_kept(:, 1);
HS_kept_y = HS_kept(:, 2);
LengthHS_kept = length(HS_kept);
radii_node2 = 8;
hold on
for i = 1:n
centers_node5 = [x(i), y(i)];
elim_circles3(i) = viscircles(centers_node5, radii_node2, 'color', 'k', 'linestyle', '--');
end
for j = 1:LengthHS_kept
centers_HS_kept = [HS_kept_x(j), HS_kept_y(j)];
elim_circles4(j) = viscircles(centers_HS_kept, radii_node2, 'color', 'k', 'linestyle', '--');
end
CTR Demo Incomplete 2.PNG
  20 个评论
Vance Blake
Vance Blake 2019-8-28
编辑:Vance Blake 2019-8-28
Hey Adam I figured it out it was this line "[elim_dist2 = nan(numel(x))]" causing the problems because it sets up a NaN matrix based on the size of x whcih has 10 elements instead of the size i need for my second elimination. Took me a bit to see it but I went line by line running each piece of code individually like you suggested and figured it out. Thanks for putting up with my ignorance and all your help with my problems. make this an answer so that i can accpet it and give you the credit you deserve.
Adam Danz
Adam Danz 2019-8-28
Going line-by-line is often the best way to troubleshoot code and to really understand what's happening in the code. Well done!

请先登录,再进行评论。

采纳的回答

Adam Danz
Adam Danz 2019-8-28
Summary of the discussion in the comment section under the question:
A matrix was pre allocated incorrectly which led to indexing problems.

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by