Matlab help!! compute grosper curve

Maths and statistics discussion, revision, exam and homework help.

This thread is sponsored by:
Announcements Posted on
Important: please read these guidelines before posting about exams on The Student Room 28-04-2013
Sign in to Reply
  1. alexlct054's Avatar
    • Junior Member
    • Posts: 29
    Matlab help!! compute grosper curve
    Gosper curve, 4 steps
    Axiom: XF
    Production rules:
    Newx=X+YF++YF-FX- - FXFX-YF+
    Newy=-FX+YFYF+ + YF+FX- - FX-Y
    Constants: alpha=0; θ=pi/3


    The following is what I have done so far. However there is a problem of my matlab code, which is not a correct graph for Gosper curve, which is not matched to the Gosper curve in wikipedia. Many anyone help me to check the mistake please? Many thanks for helping!!


    function [X,Y]=Gosper_curve(Lmax)
    Axiom='XF';
    Newf='F';
    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,Newf,Newx,N ewy,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,Newf,Newx,N ewy,alpha,theta)
    Rule=Gosper_syst(Lmax,Axiom,Newf ,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/(2^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;
    function z1=Gosper_syst(Lmax,Axiom,Newf,N ewx,Newy,n,tmp)
    if n<=Lmax
    if n==1
    tmp=Axiom;
    end
    M=length(tmp);
    tmp1='';
    for i=1:M
    if tmp(i)=='F'
    tmp1=strcat(tmp1,Newf);
    end
    if tmp(i)=='X'
    tmp1=strcat(tmp1,Newx);
    end
    if tmp(i)=='Y'
    tmp1=strcat(tmp1,Newy);
    end
    if not(tmp(i)=='F') &&not(tmp(i)=='X') &&not(tmp(i)=='Y')
    tmp1=strcat(tmp1,tmp(i));
    end
    end
    tmp=tmp1;
    n=n+1;
    tmp=Gosper_syst(Lmax,Axiom,Newf, Newx,Newy,n,tmp);
    end
    z1=tmp;
  2. Coursework.info's Avatar
    • Retired TSR Help Bot
    • Location: That galaxy over there
    Matlab help!! compute grosper curve
    It's been a while since you posted and nobody's replied yet...maybe you should check out MarkedbyTeachers.com, TSR's sister site. It has the largest library of essays in the UK.

    They've got over 181,000+ coursework, essays, homeworks etc.. all written by GCSE, A Level, University and IB students across all topics. You get access either by publishing some of your own work, or paying £4.99 for a month's access. Both ways give you unlimited access to all of the essays.

    All their documents are submitted to Turnitin anti-plagiarism software, so it can't be misused, and the site's used by hundreds of thousands of UK teachers and students.

    What's more, you can take a look around the site and preview the work absolutely free. Click here to find out more...
Sign in to Reply
Share this discussion:  
Article updates
Moderators

We have a brilliant team of more than 60 volunteers looking after discussions on The Student Room, helping to make it a fun, safe and useful place to hang out.

Reputation gems:
The Reputation gems seen here indicate how well reputed the user is, red gem indicate negative reputation and green indicates a good rep.
Post rating score:
These scores show if a post has been positively or negatively rated by our members.