title: Average of of 2 coordinates
body: <p>So I am making a graph of the average between to lists of coordinates. </p>
  
  <p>So I have been looking all over and can't seem to find any information on how I can find the average of the 2 lists of values. When I try I get an error "the index was outside the matrix boundaries" and when I got it to work I just made a graph where the years where extremely high and the graph itself were looking insane. What i do is importing 2 parts of(data/data2) information with Json.</p>
  
  <pre><code>        //
          // Data
          //
  
          int tal = dataSet.dataset.value.Count;
          //Add items in the listview
          int[] yData = new int[tal];
          int[] xData = new int[tal];
          int k = 0;
  
          foreach (var item in dataSet.dataset.dimension.Tid.category.label)
          {
              xData[k++] = int.Parse(item.Value.ToString());
          }
  
          for (int i = 0; i &lt; tal; i++)
          {
              yData[i] = dataSet.dataset.value[i];
          }
  
          //
          // Data2
          //
  
          int tal2 = dataSet2.dataset.value.Count;
          int[] y2Data = new int[tal2];
          int[] x2Data = new int[tal2];
          int j = 0;
  
          foreach (var item in 
          dataSet2.dataset.dimension.Tid.category.label)
          {
              x2Data[j++] = int.Parse(item.Value.ToString());
          }
  
          for (int p = 0; p &lt; tal2; p++)
          {
              y2Data[p] = dataSet2.dataset.value[p];
          }
  
  
           This is the part
          /////////////////////////////////////////////////////////// 
          int[] ySum = new int[xData.Length];
  
          for (int i = 0; i &lt; xData.Length; i++)
          {
              ySum[i] = (yData[i] + y2Data[i]) / 2;
  
          }
          /////////////////////////////////////////////////////////// 
  
  
          List&lt;int&gt; GenUd = new List&lt;int&gt;(yData.ToList());
          textBoxGenUd.Text = GenUd.Average().ToString();
          List&lt;int&gt; GenInd = new List&lt;int&gt;(y2Data.ToList());
          textBoxGenInd.Text = GenInd.Average().ToString();
  
  
          chartArea1.Name = "ChartArea1";
          chart2.ChartAreas.Add(chartArea1);
          chart2.Dock = DockStyle.Fill;
  
  
  
          for (int i = 0; i &lt;xData.Count(); i++)
          {
              series1.Points.AddXY(ySum[i], x2Data[i]);
          }
  
          MySecChart2 mc3 = new MySecChart2(series1); 
          mc3.ShowDialog();
  </code></pre>