C# My ArrayList only contains the last item
<p>I have the following code in C# Visual Studio.I am trying to plot data using MATLAB through COM server. I am able to do so somewhat, but with the code I have, the MATLAB output console only shows the last value for the variable "numbers" and when it plots, it overwrites all the previous values. Also, how can i make the variable size dynamic?My goal is to plot the data real time. Any suggestion would be appreciated!</p>

<pre><code>     using System;
     using System.Collections.Generic;
     using System.Linq;
     using System.Text;
     using System.Threading.Tasks;

     namespace ConsoleApplication4
      {
         class Program
         {
    static void Main(string[] args)
    {
        ////// Create the MATLAB instance 
        MLApp.MLApp matlab = new MLApp.MLApp();

        for (int j = 1; j &lt;= 10; j++)
        {
            int[] numbers = new int[11];
            numbers[j] = j * 15;
            matlab.Execute("numbers");
            matlab.PutWorkspaceData("A", "base",numbers);
            matlab.Execute("plot(A);");
        }
        //    //Console.WriteLine(j*15);
        //}
        //Console.ReadKey();
    }
}
</code></pre>

<p>}</p>

<p>UPDATE:</p>

<pre><code>  var numbers = new List&lt;int&gt;();
        for (int j = 1; j &lt;= 10; j++)
        {
            //numbers[j] = j * 15;
           int val= j * 15;
            numbers.Add(val);
            var array = numbers.ToArray();
            matlab.Execute("array");
            matlab.PutWorkspaceData("A", "base", array);
            matlab.Execute("plot(A);");
         }
</code></pre>