title: How to remove training dataset from a Matlab Generalized Linear Model object
body: <p>I have a classification model in matlab2015a generated using </p>
  
  <pre><code>glm =  fitglm(Ttrain,...)
  </code></pre>
  
  <p>I want to keep glm and pass it around, but matlab also keeps the training data (Ttrain - a table) bound to the object. This can become prohibitive if you have many models + large training data sets (you can easily run out of memory). However doing something naive like setting:</p>
  
  <pre><code>glm.Variables= [];
  </code></pre>
  
  <p>gives</p>
  
  <pre><code>Error using classreg.regr.FitObject/subsasgn (line 753)
  The Variables property for class GeneralizedLinearModel is read-only.
  </code></pre>
  
  <p>How do I discard the training data from the linear model, but still be able to use all the convenience and safety of calling <code>glm.predict(...)</code>? (I could of course rip out the regression coefficients and do the predict logic myself, but I prefer not to)</p>