Maximum Recursion limit of 500 Reached Error.

I am using this code to plot number of circles. However, when I run it says that Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N) to change the limit. How to correct this error?
function h = circle3(x,y,r)
d = r*2;
px = x-r;
py = y-r;
h = rectangle('Position',[px py d d],'Curvature',[1,1]);
daspect([1,1,1])
for i =1:20
x=0 + (5+5)*rand(1)
y=0 + (5+5)*rand(1)
r=0.5
circle3(x,y,r)
hold on
end

Respuestas (2)

James Tursa
James Tursa el 2 de Feb. de 2018
Editada: James Tursa el 2 de Feb. de 2018

2 votos

You need to rewrite your logic so that your circle3 function has a way to return to the caller. As it is now, the only thing that circle3 does is call circle3, which calls circle3, which calls circle3, etc.

1 comentario

Iqbal Farjad
Iqbal Farjad el 2 de Feb. de 2018
Can you please assist me with that or give me an example how can I rewrite?

Iniciar sesión para comentar.

Matt J
Matt J el 2 de Feb. de 2018
Editada: Matt J el 2 de Feb. de 2018
The code which invokes circle3() should be placed elsewhere. circle3() should contain only the following,
function h = circle3(x,y,r)
d = r*2;
px = x-r;
py = y-r;
h = rectangle('Position',[px py d d],'Curvature',[1,1]);
daspect([1,1,1])
end

1 comentario

Matt J
Matt J el 2 de Feb. de 2018
Incidentally, if you have the Image Processing Toolbox, just use VISCIRCLES.

Iniciar sesión para comentar.

Categorías

Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 2 de Feb. de 2018

Editada:

el 2 de Feb. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by