title: Change string values to number in Matlab table
body: <p>I am using Matlab2015b. And I would like to read a simple csv file to a table and change its string values to corresponding numeric values.</p>
  <p>I have following example data.</p>
  <pre><code>Var1, VarClass
  1 , attack
  2 , normal
  1, attack
  </code></pre>
  <p>I would like to change this string values to number. for example attack = 1, normal = -1.</p>
  <p>My first try.</p>
  <pre><code>T = readtable('example_data.csv', 'Delimiter',',','FileType','text','TreatAsEmpty',{'?'});
  
  rows_attack = strcmp(T(:,2),'attack');
  T(rows_attack,2) = 1
  
  rows_normal = strcmp(T(:,2),'normal');
  T(rows_normal,2) = -1
  </code></pre>
  <p>I get following error:</p>
  <p><em>Undefined function 'eq' for input arguments of type 'cell'.</em></p>
  <p>What? Which undefined function? What is 'eq'?</p>
  <p>Well. After reading some about table, I understood that supposedly higher level matlab does not override '=='. That is 'eq' which means equality. But error message certainly is not informative.</p>
  <p>Then my second try.</p>
  <pre><code>T = readtable('example_data.csv', 'Delimiter',',','FileType','text','TreatAsEmpty',{'?'});
  
  
  rows_attack = strcmp(T.VarClass,'attack');
  T(rows_attack,2) = 1
  </code></pre>
  <p>This time, I get</p>
  <p><em>Right hand side of an assignment into a table must be another table or a cell
  array.</em></p>
  <p>Well. Okay. It wants table. I will give it one.</p>
  <pre><code>T = readtable('example_data.csv', 'Delimiter',',','FileType','text','TreatAsEmpty',{'?'});
  
  rows_attack = strcmp(T.VarClass,'attack');
  rows_attack_size = sum(rows_attack);
  data_to_fill = ones(rows_attack_size,1) ;
  T(rows_attack,2) = array2table(data_to_fill);
  </code></pre>
  <p>Well. This time error message is.</p>
  <p><em>Conversion to cell from double is not possible.</em></p>
  <p>I thought that this matlab table is similar to R data-frame or python pandas DataFrame. Well, certainly it is not. Can someone guide me about how to solve this problem?</p>