From: Kevin on
I have been told to create the gosper curve, i was given the Axiom, Newx, Newy and the constants: theta and pi.
However, i cant see where it is i am going wrong or if there are small details that i am missing out, i used the code for a koch curve and dragon curve to learn/teach myself how to creat the gosper curve.

function [X,Y]=Gosper_curve(Lmax)
Axiom='XF';
Newx='X+YF++YF-FX--FXFX-YF+';
Newy='-FX+YFYF++YF+FX--FX-Y';
theta=pi/3;
alpha=0;
p=[0;0];
p=Coord(p,Lmax,Axiom,Newx,Newy,alpha,theta);
M=size(p,2);
X=p(1:1,1:M);
Y=p(2:2,1:M);
figure(1);
plot(X,Y,'Color','k');
set(gca,'xtick',[],'ytick',[]);
set(gca,'XColor','w','YColor','w');
function z=Coord(p,Lmax,Axiom,Newx,Newy,alpha,theta)
Rule=Gosper_rule(Lmax,Axiom,Newx,Newy,1,'');
M=length(Rule);
for i=1:M
Tmp=p(1:2,size(p,2):size(p,2));
if Rule(i)=='F'
R=[cos(alpha); sin(alpha)];
R=R/(4^Lmax);
Tmp=Tmp+R;
p=cat(2,p,Tmp);
end
if Rule(i)=='+'
alpha=alpha+theta;
end
if Rule(i)=='-'
alpha=alpha-theta;
end
end
z=p;

Thank you
From: Kevin on
I keep gettign these as error codes when running the code, and have no idea as to how to fix them:

>> Gosper_curve(4)
??? Undefined function or method 'Gosper_rule' for input arguments of type
'double'.

Error in ==> Gosper_curve>Coord at 17
Rule=Gosper_rule(Lmax,Axiom,Newx,Newy,1,'');

Error in ==> Gosper_curve at 8
p=Coord(p,Lmax,Axiom,Newx,Newy,alpha,theta);

i dont know if that helps anyone who is trying to help me, but i really dont know what is going on with this,
Thank you again
From: Steven Lord on

"Kevin " <kevin_stanza(a)yahoo.co.uk> wrote in message
news:hrphpi$dpl$1(a)fred.mathworks.com...
>I keep gettign these as error codes when running the code, and have no idea
>as to how to fix them:
>
>>> Gosper_curve(4)
> ??? Undefined function or method 'Gosper_rule' for input arguments of type
> 'double'.
>
> Error in ==> Gosper_curve>Coord at 17
> Rule=Gosper_rule(Lmax,Axiom,Newx,Newy,1,'');
>
> Error in ==> Gosper_curve at 8
> p=Coord(p,Lmax,Axiom,Newx,Newy,alpha,theta);
>
> i dont know if that helps anyone who is trying to help me, but i really
> dont know what is going on with this,
> Thank you again

Your original code didn't include a Gosper_rule function, and when you run
the function apparently MATLAB couldn't find that function either.

Create a file named Gosper_rule.m and create a function named Gosper_rule
inside that file. Put that file in the same directory as your
Gosper_curve.m file. Fill in that function with the appropriate contents.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ