function strw = wordwrap(str,len)
% very buggy attempt and takig a long string of words and breaking into cell
% array of shorter strings (less that LEN)
%
% John Wilkin

k = 1;
b = findstr(str,' ');
while length(str)>len
  if isempty(b)
    lenstr = min([len length(str)]);
    strw{k} = str(1:lenstr);
    str(1:lenstr)=[];    
  else  
    r1 = max(find(b<len));
    if isempty(r1)
      r1 = 1;
    end
    strw{k} = str(1:(b(r1)-1));
    str = str((b(r1)+1):length(str));
  end  
  k = k+1;    
  b = findstr(str,' ');  
end
strw{k} = str(1:length(str));
