Hi I'm trying to plot this:
function [x,y]=hilbert(n);
%HILBERT Hilbert curve.
%
% [x,y]=hilbert(n) gives the vector coordinates of points
% in n-th order Hilbert curve of area 1.
%
% Example: plot of 5-th order curve
%
% [x,y]=hilbert(5);line(x,y)
n=5
if n<=0
x=0;
y=0;
else
[xo,yo]=hilbert(n-1);
x=.5*[-.5+yo -.5+xo .5+xo .5-yo];
y=.5*[-.5+xo .5+yo .5+yo -.5-xo];
end
However I get this error message
??? Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N) to change the limit. Be aware that exceeding your available stack space can crash MATLAB and/or your computer.
Error in ==> hilbert
Anyone know how to fix this?
Everyone on the page the file is posted on says it works well but sadly I cannot get it to run.

1 Kommentar

Sean de Wolski
Sean de Wolski am 11 Mär. 2011
What did you call it with? Did you insert the overwriting of the input argument n, with n=5
?

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 11 Mär. 2011

1 Stimme

Sean is right, the problem is that n keeps getting bashed back to 5, so the recursion never ends.
He is also right to hint that it might be due the way you call it. In order to use it, you should not have that n=5 line, and you should not just press F5 when you are on the file: instead, at the command line, you should command
hilbert(5)
if what you want is the 5th order curve.

1 Kommentar

George Harrison
George Harrison am 12 Mär. 2011
Ahh I see, I was being foolish :) Thanks for the Help

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by