function i = strmatch(str,strs)
%STRMATCH Find possible matches for a string.
%	I = STRMATCH(STR,STRS) looks through the rows of string matrix STRS
%	to find strings that begin with string STR, returning the matching
%	row indices.  For example
%	
%	  i = strmatch('max',str2mat('maximum','minimax','maxstep'))
%	
%	returns i = [1 3] since rows 1 and 3 begin with the string 'max'.
%	
%	See also FINDSTR, STR2MAT, STRCMP.

%	Mark W. Reichelt, 8-29-94
%	Copyright (c) 1984-94 by The MathWorks, Inc.
%	$Revision: 1.5 $  $Date: 1995/01/17 13:42:57 $
%	$Revision: 1.5 $

[m,n] = size(strs);

len = length(str);

if len > n
  i = [];
  return;
end

if len > 1
  diffs = sum((strs(:,1:len) ~= str(ones(m,1),:))');
else 					% we have to avoid summing a vector
  diffs = ((strs(:,1:len) ~= str(ones(m,1),:))');
end  
i = find(~diffs);
