title: How can I format strings for use as structure field names in MATLAB?
body: <p>I want to remove hyphens (<code>-</code>), slashes (<code>/</code>) and white space (<code></code>) from a string <code>name(i)</code> so that I can use it as a structure field name.</p>
  
  <p>This is the ugly way I am currently doing it using the function <a href="http://www.mathworks.com/help/techdoc/ref/strrep.html" rel="noreferrer"><code>strrep</code></a>:</p>
  
  <pre><code>cell2mat(strrep(strrep(strrep(name(i), '-',''),'/',''),' ', ''))
  </code></pre>
  
  <p>I have also tried other variations, such as:</p>
  
  <pre><code>strrep(name(i),{'-','/'},{'',''});
  strrep(name(i),['-','/'],['','']);
  </code></pre>
  
  <p>What is a more efficient way of doing this?</p>