Results 1 to 2 of 2

Math Help - FUN with Matlab

  1. #1
    Senior Member
    Joined
    Jan 2009
    Posts
    296

    FUN with Matlab

    I need a Matlab function that finds the last place in a line where a double character appears (that is, where the same character appears twice in a row)

    So if the function is called locateDouble, locateDouble('adcdccd') should return 5 since inxes 5 is the first charcter of the last double character.
    I posted my attempt at the program below, but it won't work.


    function double=findDouble(line)
    place=length(line);
    while place>0;
    for j=1:length(line)-1;
    if j~==j+1
    j=j+1
    end
    end
    end
    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 zhupolongjoe View Post
    I need a Matlab function that finds the last place in a line where a double character appears (that is, where the same character appears twice in a row)

    So if the function is called locateDouble, locateDouble('adcdccd') should return 5 since inxes 5 is the first charcter of the last double character.
    I posted my attempt at the program below, but it won't work.


    function double=findDouble(line)
    place=length(line);
    while place>0;
    for j=1:length(line)-1;
    if j~==j+1
    j=j+1
    end
    end
    end
    try this:

    Code:
     
    aa='asdgghjklloperyyzt'
     
    ll=length(aa)
     
    aa1=aa(1:ll-1);
    aa2=aa(2:ll);
     
    zz=(aa1==aa2)
     
    kk=find(zz)
    Now try to use this idea.

    CB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Matlab help
    Posted in the Math Software Forum
    Replies: 1
    Last Post: February 11th 2010, 02:59 AM
  2. Matlab FFT Help
    Posted in the Math Software Forum
    Replies: 0
    Last Post: June 3rd 2009, 12:48 PM
  3. help about ODE in matlab
    Posted in the Math Software Forum
    Replies: 1
    Last Post: May 31st 2009, 03:10 AM
  4. Matlab Please help me
    Posted in the Math Software Forum
    Replies: 8
    Last Post: November 10th 2008, 04:40 PM
  5. Matlab
    Posted in the Calculus Forum
    Replies: 3
    Last Post: August 20th 2008, 10:39 PM

Search Tags


/mathhelpforum @mathhelpforum