title: How to assign values to a variable iteratively using for loop in maxima?
body: <p>I am using for loop to assign values to a variable, more precisely a matrix, in xmaxima. The values seem to get stored in the individual indices but I am unable to recall the entire matrix values by calling the matrix variable name.</p>
  
  <p>For example: </p>
  
  <p>Suppose I am assigning <code>xreal[1]=5; xreal[2]=6;...... xreal[5]=9</code>. I want xreal to have <code>[5 6 7 8 9]</code>, which is not happening.</p>
  
  <p>Below is my code. What's the right way to do this?</p>
  
  <pre><code>k:1;
  for i from 1 thru length(xvals) do (
  (if(imagpart(xvals[i]) = 0) then xreal[k]:xvals[i]),k:k+1
  );
  </code></pre>
  
  <p>Here, </p>
  
  <pre><code>xreal[1]; gives 0.06111
  xreal[2]; gives 0.080 and so on.
  </code></pre>
  
  <p>But <code>xreal</code> just gives "xreal" i.e. the variable name itself.</p>