title: generate a matrix with numbers between [0,1]
body: <p>I have to generate a matrix of n x n uniformly distributed random numbers (n read from keyboard). The numbers should be between [0,1] and then to average the numbers &gt; 0.5. I've tried the following:</p>
  <pre><code>value = 'Insert a value for n: ';
  x = input(value);
  
  matrix = rand(x,x);
  
  matrix2(matrix &lt; 0.5) = nan;
  
  average = mean(matrix2, 'omitnan');
  disp(average);
  </code></pre>
  <p>After I run the code I get that average is 0 and I don't know why.</p>