title: Find string in cell array with elements of different types
body: <p>I have a function that takes variadic arguments. These arguments are parameter-value pairs, so <code>varargin</code> is a cell array in which every odd-indexed element is a string (the parameter), but the even-indexed elements can be a string, number, or cell array of strings. I want to find the index of a particular string in <code>varargin</code>. I have a working solution, but it uses <code>arrayfun</code> twice; is there a cleaner/faster/more effective way of find a string in such a cell array? The resulting <code>index</code> will be used to remove that element and the following one from <code>varargin</code>. I would like to minimize creation of new variables.</p>
  
  <pre><code>str_to_find = 'paramX'
  finds = arrayfun(@(i) strfind(varargin{i},str_to_find), 1:length(varargin), 'UniformOutput', 0);
  finds2 = arrayfun(@(i) ~iscell(finds{i}) &amp;&amp; ~isempty(finds{i}), 1:length(finds));
  index = find(finds2==1);
  
  varargin(index)=[];
  varargin(index)=[];
  </code></pre>
  
  <p>Given <code>varargin</code> is <code>{'paramA', 'valueA', 'paramB', 9, 'paramX', {'z','x','c'}</code>, then <code>finds</code> is <code>[] [] [] [] [1] {1x3 cell}</code>, <code>finds2</code> is <code>0 0 0 0 1 0</code>, and <code>index</code> is <code>5</code>. So, my solution does what I need, but it just seems ugly. I would just use <code>finds2</code> (i.e., not create <code>index</code>) to delete that element from <code>varargin</code>, but I also need to remove the one after it.</p>