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