
Originally Posted by
zhupolongjoe
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