title: chi2test in MATLAB -- vector different length
body: <p>I have 3 data vectors representing the gender (0=male, 1=female) of 3 groups A, B, C.</p>
  
  <p>for example</p>
  
  <pre><code>A = [0 0 0 0 1 1 1 1 0 0];
  B = [1 1 1 1 1 1 1 0];
  C = [1 0 0 1 0 1 1 0 1 1 1 1 1];
  </code></pre>
  
  <p>and relative number of male and female</p>
  
  <pre><code>n_maleA =6;
  n_femaleA =4;
  n_maleB = 1;
  n_femaleB = 7;
  n_maleC = 4;
  n_femaleC = 9;
  </code></pre>
  
  <p>I would like to know if there are significant differences in gender between the 3 groups. To do this I read that is possible to use</p>
  
  <pre><code>[tbl,chi2stat,pval] = crosstab(x1,x2)
  </code></pre>
  
  <p>How can I use this with more than 2 groups of data and with data that have different length? Is there any other way to perform the chi-squared test in MATLAB that suits with my case? </p>
  
  <p>Thanks in advance</p>