title: how to vectorize this string split function in Matlab
body: <p>How can I vectorize this strsplit function in Matlab so that it runs faster? Thank you</p>
  
  <pre><code>function parts = strsplit(splitstr, str)
    splitlen = length(splitstr);
    k = strfind(str, splitstr);
    parts = cell(length(k)+1, 1);
    s = 1;
  
    if isempty(k)
      parts{1} = str;
      return
    end
  
    for i=1:length(k)
      parts{i} = str(s : k(i)-1);
      s = k(i) + splitlen ;
    end
  
    parts{end} = str((k(end) + splitlen) : end); 
  </code></pre>