title: Why is day() function throwing me this error: Check for missing argument or incorrect argument data type in call to function 'day'?
body: <p>Having this long task that I will resume:</p>
  
  <p>Perform a regression model over the normalized active cases in China using the model.....(long assignment that I'm not worried about and will save you time). <strong>Tip: To convert from datetime to a numeric variable for the regression, use <code>x=day(date-min(date(:)))+1;</code> being “date” the datetime vector return from getdata function.</strong></p>
  
  <p>This is what I have:</p>
  
  <pre><code>function RP_ejercicio1
  
      data = readtable('COVID-19.csv');
      [active_res, confirmed_res, death_res, recovered_res, date]  = getdata(data, 'China', 93/147);
  
      x=day(date-min(date(:)))+1;
      y = active_res;
      yp = log(y./x);
      a = [x ones(size(x))];
      sol = inv(a'*a)*(a'*yp);
      b = sol(1);
      c = sol(2);
      a = exp(c);
  
  end
  </code></pre>
  
  <p>I get this error: <code>Check for missing argument or incorrect argument data type in call to function 'day'.</code> In this line: <code>x=day(date-min(date(:)))+1;</code>. The one that is supposed to help as a tip is giving me a headache. I can ensure that <code>date</code> is a 1x50 datetime array after executing the getdata function.</p>
  
  <p>Am I doing something wrong? Is the tip wrong? And if it's the second case, is there other way to do the same?</p>
  
  <p>I add an image for more clarity:</p>
  
  <p><a href="https://i.stack.imgur.com/6XbG1.png" rel="nofollow noreferrer">Date array</a></p>