Results 1 to 13 of 13

Math Help - Matlab help plots, finding nth number....

  1. #1
    Junior Member
    Joined
    Feb 2009
    Posts
    29

    Matlab help plots, finding nth number....

    1) COOLnumbers are the sequence 1, 1, 2, 3, 5, 8, 13, 21, 34 … As you can (probably) see, each COOL number is the sum of the previous two. ugly numbers, on the other hand, are the sum of the previous three.
    a. Find the 19th and 119th ugly numbers.
    b. Use “bar” to give a bar plot of the first 10 ugly numbers. Label your axes.
    c. Plot the first 100 ugly numbers on a logarithmic y-scale. Do you notice anything? What might it mean?


    Can anyone help me make this script for matlab?
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Mathhelpz View Post
    1) COOLnumbers are the sequence 1, 1, 2, 3, 5, 8, 13, 21, 34 … As you can (probably) see, each COOL number is the sum of the previous two. ugly numbers, on the other hand, are the sum of the previous three.
    a. Find the 19th and 119th ugly numbers.
    b. Use “bar” to give a bar plot of the first 10 ugly numbers. Label your axes.
    c. Plot the first 100 ugly numbers on a logarithmic y-scale. Do you notice anything? What might it mean?


    Can anyone help me make this script for matlab?
    We need the first three "ugly numbers" before we can start.

    CB
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Junior Member
    Joined
    Feb 2009
    Posts
    29
    alright ill get back to you,
    could you put like what general matlab script i need to know? Like how would i find the nth term, using bar, and then plotting?
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Mathhelpz View Post
    alright ill get back to you,
    could you put like what general matlab script i need to know? Like how would i find the nth term, using bar, and then plotting?
    The first 100 will be produced by:

    Code:
    TriNacci=zeros(1:100);
    
    TriNacci(1:3)=[1,1,2];  %put the three initial values here
    
    for idx=4:100
      TriNacci(idx)=TriNacci(idx-3)+TriNacci(idx-2)+TriNacci(idx-1);
    end
    or you could solve the recurrence and code the solution as a function of n

    CB
    Last edited by CaptainBlack; March 8th 2010 at 12:10 PM.
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Junior Member
    Joined
    Feb 2009
    Posts
    29
    can you check if this is correct??


    for n=1:119
    phi=(1+sqrt(5))*(1/2);
    F=((phi^n)-(1-phi)^n)/sqrt(5);
    bar(1:10 ,F)
    xlabel('numbers')
    ylabel('range')
    semilogy(1:100 ,F)
    end;
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Newbie
    Joined
    Mar 2010
    Posts
    11
    I would say that

    "
    u(1)=1;
    u(2)=1;

    for kk=3:100;
    u(kk)=u(kk-1)+u(kk-2);
    end
    "

    would do the trick. Looking to u on a logaritmic Yscale you see a straight line. This indicates that u is some kind of logaritmic function.
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Mathhelpz View Post
    can you check if this is correct??


    for n=1:119
    phi=(1+sqrt(5))*(1/2);
    F=((phi^n)-(1-phi)^n)/sqrt(5);
    bar(1:10 ,F)
    xlabel('numbers')
    ylabel('range')
    semilogy(1:100 ,F)
    end;
    Check what? These are the Fibonacci numbers (your so called COOL numbers) not your UGLY numbers.

    CB
    Follow Math Help Forum on Facebook and Google+

  8. #8
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Jeroentje View Post
    I would say that

    "
    u(1)=1;
    u(2)=1;

    for kk=3:100;
    u(kk)=u(kk-1)+u(kk-2);
    end
    "

    would do the trick. Looking to u on a logaritmic Yscale you see a straight line. This indicates that u is some kind of logaritmic function.
    These are also the COOL-Fibonacci numbers.

    CB
    Follow Math Help Forum on Facebook and Google+

  9. #9
    Junior Member
    Joined
    Feb 2009
    Posts
    29
    Thanks for the help !
    Follow Math Help Forum on Facebook and Google+

  10. #10
    Newbie
    Joined
    Mar 2010
    Posts
    11
    "
    u(1)=1;
    u(2)=1;
    u(3)=2;

    for kk=4:100;
    u(kk)=u(kk-1)+u(kk-2)+u(kk-3);
    end
    "
    Follow Math Help Forum on Facebook and Google+

  11. #11
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Jeroentje View Post
    "
    u(1)=1;
    u(2)=1;
    u(3)=2;

    for kk=4:100;
    u(kk)=u(kk-1)+u(kk-2)+u(kk-3);
    end
    "
    Which has already been posted in message #4 in this thread (only with better syntax)

    CB
    Follow Math Help Forum on Facebook and Google+

  12. #12
    Junior Member
    Joined
    Feb 2009
    Posts
    29
    i need help doing the bar plot....

    u(1)=0;
    u(2)=1;
    u(3)=1;

    for kk=4:119;
    u(kk)=u(kk-1)+u(kk-2)+u(kk-3);
    end

    Find1 = u(19);
    Find2 = u(119);

    That's the program and it works for what i want to find.
    How to I do the bar plot part..

    * a. Use “bar” to give a bar plot of the first 10 ugly numbers. Label your axes.*


    I Tried doing like bar (range(1:10))*u or something but that doens't seem right... Hope you can help
    Last edited by Mathhelpz; March 10th 2010 at 07:22 PM.
    Follow Math Help Forum on Facebook and Google+

  13. #13
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Mathhelpz View Post
    i need help doing the bar plot....

    u(1)=0;
    u(2)=1;
    u(3)=1;

    for kk=4:119;
    u(kk)=u(kk-1)+u(kk-2)+u(kk-3);
    end

    Find1 = u(19);
    Find2 = u(119);

    That's the program and it works for what i want to find.
    How to I do the bar plot part..

    * a. Use “bar” to give a bar plot of the first 10 ugly numbers. Label your axes.*


    I Tried doing like bar (range(1:10))*u or something but that doens't seem right... Hope you can help
    bar(u(1:10));

    CB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. MATLAB: Coloring surf-plots
    Posted in the Math Software Forum
    Replies: 0
    Last Post: May 20th 2010, 10:08 AM
  2. Matlab - Random Number between 1 .. n
    Posted in the Math Software Forum
    Replies: 2
    Last Post: March 16th 2010, 05:55 PM
  3. Matlab Help closest next number
    Posted in the Math Software Forum
    Replies: 3
    Last Post: March 15th 2010, 09:50 PM
  4. MatLab plots with legends.
    Posted in the Math Software Forum
    Replies: 3
    Last Post: February 28th 2009, 02:08 PM
  5. Matlab: Number formating
    Posted in the Math Software Forum
    Replies: 1
    Last Post: April 7th 2008, 09:39 AM

Search Tags


/mathhelpforum @mathhelpforum