function[compare,in]=naive_search(t,p)
m=length(p);
n=length(t);
win=0;
if(n==0)
fprintf('the string is empty');
else if(m==0)
fprintf('the pattern is not present');
else
for counter=1:n-m
if (p(counter)==t(counter))
counter;
win=1+win;
end
win;
end
end
> for counter=1:n-m
> if (p(counter)==t(counter))
> counter;
> win=1+win;
> end
> win;
> end
> end
At each for loop iteration you should compare a substring of t with p.
What you did is just comparing one (1) character of each.
Bruno