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 件のコメント

Sean de Wolski
Sean de Wolski 2011 年 3 月 11 日
What did you call it with? Did you insert the overwriting of the input argument n, with n=5
?

サインインしてコメントする。

 採用された回答

Walter Roberson
Walter Roberson 2011 年 3 月 11 日

1 投票

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 件のコメント

George Harrison
George Harrison 2011 年 3 月 12 日
Ahh I see, I was being foolish :) Thanks for the Help

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by