Results 1 to 4 of 4

Math Help - i don't know where is it wrong

  1. #1
    Newbie
    Joined
    Jul 2009
    From
    malaysia
    Posts
    3

    i don't know where is it wrong

    plz help me, im newbie in matlab.. ive tried so many ways to make sure it is correct but then still cannot work out..

    i hv to do some iteration, and plot as well (save the answer in other place since the answer quite long)

    function a = lukis(a0,s,n)


    lamda = 1.0*(10e-6);
    m = 2;
    a(1) = a0;

    for i = 1:n
    a(i+1) = a(i) + lamda * a(i).^(m/2) * s.^m

    if(a(i+1)>1)
    break;
    end
    end
    plot(a(i+1))

    hold on

    save('lukis', 'a(i+1)')

    to run in c/w : lukis(1.0*10e-10,0.5,1000)

    thanks.
    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 anizatie View Post
    plz help me, im newbie in matlab.. ive tried so many ways to make sure it is correct but then still cannot work out..

    i hv to do some iteration, and plot as well (save the answer in other place since the answer quite long)

    function a = lukis(a0,s,n)


    lamda = 1.0*(10e-6);
    m = 2;
    a(1) = a0;

    for i = 1:n
    a(i+1) = a(i) + lamda * a(i).^(m/2) * s.^m

    if(a(i+1)>1)
    break;
    end
    end
    plot(a(i+1))

    hold on

    save('lukis', 'a(i+1)')

    to run in c/w : lukis(1.0*10e-10,0.5,1000)

    thanks.
    Code:
    function a = lukis(a0,s,n)
     
    lamda = 1.0*(10e-6);
    m = 2;
    a=zeros(1,n);
    a(1) = a0;
     
    for i = 1:n-1
      a(i+1) = a(i) + lamda * a(i).^(m/2) * s.^m
     
      if(a(i+1)>1)
        break;
      end
    end
     
    plot(a(i+1))
     
    hold on
     
    save('lukis', 'a')
    CB
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Jul 2009
    From
    malaysia
    Posts
    3
    Quote Originally Posted by CaptainBlack View Post
    Code:
    function a = lukis(a0,s,n)
     
    lamda = 1.0*(10e-6);
    m = 2;
    a=zeros(1,n);
    a(1) = a0;
     
    for i = 1:n-1
      a(i+1) = a(i) + lamda * a(i).^(m/2) * s.^m
     
      if(a(i+1)>1)
        break;
      end
    end
     
    plot(a(i+1))
     
    hold on
     
    save('lukis', 'a')
    CB

    thanks for your reply. its helping me a lot but when the value of a(i+1)>1, the operation still go on, the iterations should stop when a(i+1) reach 1.

    by looking at the program, it seem notin wrong there.. hope u can help me.. thanks.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Newbie
    Joined
    Jul 2009
    From
    malaysia
    Posts
    3
    i have found another way to solve this problem... thank you.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. [SOLVED] am I wrong here or is my textbook wrong??
    Posted in the Algebra Forum
    Replies: 5
    Last Post: September 25th 2011, 05:13 PM
  2. IVP, what am I doing wrong?
    Posted in the Differential Equations Forum
    Replies: 4
    Last Post: February 9th 2010, 11:17 PM
  3. Replies: 6
    Last Post: August 12th 2009, 02:15 AM
  4. Why am I wrong?!
    Posted in the Calculus Forum
    Replies: 1
    Last Post: April 18th 2009, 07:34 PM
  5. Wrong answer key or wrong me ?
    Posted in the Algebra Forum
    Replies: 2
    Last Post: July 2nd 2008, 04:42 AM

Search Tags


/mathhelpforum @mathhelpforum