# extracting

### Question

• I take the tenth number in the ten data, and the result is a very high frequency (a very small period) of sine wave, which becomes a very large sine wave, how do you solve it?

Sampling rate is 500, 500 a second number, I need to display data from 30 seconds, namely 15000 figures, but the data is too much, I take the tenth is 10 Numbers, and then on the chart, results: the results of a small (cycle) high frequency sine wave, into a cycle of a sine wave

for(int i=0;i<list.count();i++){

if(i%10==0){

}

}

• Edited by Friday, May 5, 2017 3:38 AM
Thursday, May 4, 2017 1:42 AM

### All replies

• How do you solve what? Your question isn't clear ...

~~Bonnie DeWitt [C# MVP]

http://geek-goddess-bonnie.blogspot.com

Thursday, May 4, 2017 4:45 AM
• Based on his other questions, he's probably still building his data analysis application.

The data container type is unknown (probably List<T> of some numerical type), the problem description is not clear (you mean "When I sample every tenth number from the data, the result becomes a very large sine wave"?), and the type of help requested is not clear (define "solve it").

E_NOT_AN_ACTIONABLE_ITEM

EDIT: Okay, I'll try to make some sense out of it. You probably have forgotten to adjust the unit of X-axis.

When you increase the density of data, you increase the unit of X-axis (say, from 1 to 10) to produce the same curve. When you decrease the density of data (i.e.: sampling), you need to decrease the unit of X-axis (say, from 1 to 0.1)

Also note that if the sampling rate is not a divisible constant of the wave's frequency, the magnitude of the wave will change and/or become uneven.

Thursday, May 4, 2017 6:18 AM
• Sampling rate of 100, the 100 Numbers, a second digital I take ten number ten, the result of a small (cycle) high frequency sine wave, into a cycle of sine wave, how to solve?

Friday, May 5, 2017 3:32 AM
• Sampling rate is 500, 500 a second number, I need to display data from 30 seconds, namely 15000 figures, but the data is too much, I take the tenth is 10 Numbers, and then on the chart, results: the results of a small (cycle) high frequency sine wave, into a cycle of a sine wave

Friday, May 5, 2017 3:35 AM
• Humm... Maybe you could post in Chinese so I can do you a favor to translate it. Still cannot grip what you're trying to do.
Friday, May 5, 2017 3:51 AM
• Sampling rate is 500, 500 a second number, I need to display data from 30 seconds, namely 15000 figures, but the data is too much, I take the tenth is 10 Numbers, and then on the chart, results: the results of a small (cycle) high frequency sine wave, into a cycle of a sine wave

Hi,

do you mean something like this:

[using System.Windows.Forms.DataVisualization.Charting; needed]

```    public partial class Form1 : Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.DataVisualization.Charting.Chart chart1;
private System.Windows.Forms.Button button2;

private double _amplitude = 100.0;
private int _samplingRate = 100;
private bool _filtered;
private DataPointCollection _dataPoints;
private int _amountFilter = 25;

public Form1()
{
InitializeComponent();
Init();
this.button1.Click += Button1_Click;
this.button2.Click += Button2_Click;
}

//usually done in the designer...
private void Init()
{
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
this.button1 = new System.Windows.Forms.Button();
this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.button2 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(33, 374);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
//
// chart1
//
chartArea1.Name = "ChartArea1";
legend1.Name = "Legend1";
this.chart1.Location = new System.Drawing.Point(33, 31);
this.chart1.Name = "chart1";
series1.ChartArea = "ChartArea1";
series1.Legend = "Legend1";
series1.Name = "Series1";
this.chart1.Size = new System.Drawing.Size(801, 300);
this.chart1.TabIndex = 1;
this.chart1.Text = "chart1";
//
// button2
//
this.button2.Location = new System.Drawing.Point(180, 374);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 2;
this.button2.Text = "button2";
this.button2.UseVisualStyleBackColor = true;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(897, 455);
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit();
this.ResumeLayout(false);
}

private void Button2_Click(object sender, EventArgs e)
{
if (_filtered)
_filtered = false;
else
_filtered = true;

FilterData();
}

private void FilterData()
{
if (this.chart1.Series.Count > 0)
if (_filtered)
{
this._dataPoints = this.chart1.Series[0].Points;
int step = this._dataPoints.Count / _amountFilter;

this.chart1.Series.Clear();
Series d = new Series();
for (int i = 0; i < _dataPoints.Count; i+= step)

}
else
{
this.chart1.Series.Clear();
Series d = new Series();
for (int i = 0; i < _dataPoints.Count; i++)

}
}

private void Button1_Click(object sender, EventArgs e)
{
if (_samplingRate == 100)
_samplingRate = 500;
else
_samplingRate = 100;

}

private void Form1_Load(object sender, EventArgs e)
{
}

{
this.chart1.Series.Clear();

double[] data = new double[_samplingRate];

for (int i = 0; i < _samplingRate; i++)
data[i] = Math.Sin(2 * Math.PI * i / _samplingRate) * _amplitude;

Series d = new Series();
for (int i = 0; i < data.Length; i++)

}
}```

Regards,

Thorsten

Friday, May 5, 2017 4:00 AM
• Sampling rate is 500, 500 a second number, I need to display data from 30 seconds, namely 15000 figures, but the data is too much, I take the tenth is 10 Numbers, and then on the chart, results: the results of a small (cycle) high frequency sine wave, into a cycle of a sine wave

Hi,

do you mean something like this:

[using System.Windows.Forms.DataVisualization.Charting; needed]

```    public partial class Form1 : Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.DataVisualization.Charting.Chart chart1;
private System.Windows.Forms.Button button2;

private double _amplitude = 100.0;
private int _samplingRate = 100;
private bool _filtered;
private DataPointCollection _dataPoints;
private int _amountFilter = 25;

public Form1()
{
InitializeComponent();
Init();
this.button1.Click += Button1_Click;
this.button2.Click += Button2_Click;
}

//usually done in the designer...
private void Init()
{
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
this.button1 = new System.Windows.Forms.Button();
this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.button2 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(33, 374);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
//
// chart1
//
chartArea1.Name = "ChartArea1";
legend1.Name = "Legend1";
this.chart1.Location = new System.Drawing.Point(33, 31);
this.chart1.Name = "chart1";
series1.ChartArea = "ChartArea1";
series1.Legend = "Legend1";
series1.Name = "Series1";
this.chart1.Size = new System.Drawing.Size(801, 300);
this.chart1.TabIndex = 1;
this.chart1.Text = "chart1";
//
// button2
//
this.button2.Location = new System.Drawing.Point(180, 374);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 2;
this.button2.Text = "button2";
this.button2.UseVisualStyleBackColor = true;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(897, 455);
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit();
this.ResumeLayout(false);
}

private void Button2_Click(object sender, EventArgs e)
{
if (_filtered)
_filtered = false;
else
_filtered = true;

FilterData();
}

private void FilterData()
{
if (this.chart1.Series.Count > 0)
if (_filtered)
{
this._dataPoints = this.chart1.Series[0].Points;
int step = this._dataPoints.Count / _amountFilter;

this.chart1.Series.Clear();
Series d = new Series();
for (int i = 0; i < _dataPoints.Count; i+= step)

}
else
{
this.chart1.Series.Clear();
Series d = new Series();
for (int i = 0; i < _dataPoints.Count; i++)

}
}

private void Button1_Click(object sender, EventArgs e)
{
if (_samplingRate == 100)
_samplingRate = 500;
else
_samplingRate = 100;

}

private void Form1_Load(object sender, EventArgs e)
{
}

{
this.chart1.Series.Clear();

double[] data = new double[_samplingRate];

for (int i = 0; i < _samplingRate; i++)
data[i] = Math.Sin(2 * Math.PI * i / _samplingRate) * _amplitude;

Series d = new Series();
for (int i = 0; i < data.Length; i++)

}
}```

Regards,

Thorsten

Hello, I mean, the sample rate of 500, 500 data one second, I need a screen display data from 30 seconds, the 15000 data, but the data too much, so I need to throw away some, my way is: now I % 20 = = 0, 25 data fetched in 500 data, drawing pattern,

But a very small sine wave, high frequency cycle might consist of 50 data before, but I'm over it, the result is cycle small sinusoidal into a cycle of sine

Friday, May 5, 2017 4:33 AM
• Hello, I mean, the sample rate of 500, 500 data one second, I need a screen display data from 30 seconds, the 15000 data, but the data too much, so I need to throw away some, my way is: now I % 20 = = 0, 25 data fetched in 500 data, drawing pattern,

But a very small sine wave, high frequency cycle might consist of 50 data before, but I'm over it, the result is cycle small sinusoidal into a cycle of sine

Friday, May 5, 2017 4:33 AM

Friday, May 5, 2017 4:33 AM

Friday, May 5, 2017 4:35 AM

Hi,

using System.Windows.Forms.DataVisualization.Charting; needed]

```    public partial class Form1 : Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.DataVisualization.Charting.Chart chart1;
private System.Windows.Forms.Button button2;

private double _amplitude = 100.0;
private int _samplingRate = 100;
private DataPointCollection _dataPoints;
private int _amountFilter = 25;
private int _durationDisplay = 1;

public Form1()
{
InitializeComponent();
Init();
this.button1.Click += Button1_Click;
this.button2.Click += Button2_Click;
}

//usually done in the designer...
private void Init()
{
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
this.button1 = new System.Windows.Forms.Button();
this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.button2 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(33, 374);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
//
// chart1
//
chartArea1.Name = "ChartArea1";
legend1.Name = "Legend1";
this.chart1.Location = new System.Drawing.Point(33, 31);
this.chart1.Name = "chart1";
series1.ChartArea = "ChartArea1";
series1.Legend = "Legend1";
series1.Name = "Series1";
this.chart1.Size = new System.Drawing.Size(801, 300);
this.chart1.TabIndex = 1;
this.chart1.Text = "chart1";
//
// button2
//
this.button2.Location = new System.Drawing.Point(180, 374);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 2;
this.button2.Text = "button2";
this.button2.UseVisualStyleBackColor = true;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(897, 455);
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit();
this.ResumeLayout(false);
}

private void Button2_Click(object sender, EventArgs e)
{
if (_durationDisplay > 1)
_durationDisplay = 1;
else
_durationDisplay = 5;

}

private void Button1_Click(object sender, EventArgs e)
{
if (_samplingRate == 100)
_samplingRate = 500;
else
_samplingRate = 100;

}

private void Form1_Load(object sender, EventArgs e)
{
}

{
this.chart1.Series.Clear();

double[] data = new double[_samplingRate];

for (int i = 0; i < _samplingRate; i++)
data[i] = Math.Sin(2 * Math.PI * (i * _durationDisplay) / _samplingRate) * _amplitude;

Series d = new Series();
for (int i = 0; i < data.Length; i++)

}
}```

Regards,

Thorsten

Friday, May 5, 2017 5:32 AM
• ... or do you mean to keep a nice shaped wave form in the display? If so, additionally to changing the duration you have to increase the samplingrate by a factor... like:

using System.Windows.Forms.DataVisualization.Charting; needed]

```    public partial class Form1 : Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.DataVisualization.Charting.Chart chart1;
private System.Windows.Forms.Button button2;

private double _amplitude = 100.0;
private int _samplingRate = 100;
private int _durationDisplay = 1;
private int _incFactor = 1;

public Form1()
{
InitializeComponent();
Init();
this.button1.Click += Button1_Click;
this.button2.Click += Button2_Click;
}

//usually done in the designer...
private void Init()
{
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
this.button1 = new System.Windows.Forms.Button();
this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.button2 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(33, 374);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
//
// chart1
//
chartArea1.Name = "ChartArea1";
legend1.Name = "Legend1";
this.chart1.Location = new System.Drawing.Point(33, 31);
this.chart1.Name = "chart1";
series1.ChartArea = "ChartArea1";
series1.Legend = "Legend1";
series1.Name = "Series1";
this.chart1.Anchor = AnchorStyles.Left | AnchorStyles.Right;
this.chart1.Size = new System.Drawing.Size(801, 300);
this.chart1.TabIndex = 1;
this.chart1.Text = "chart1";
//
// button2
//
this.button2.Location = new System.Drawing.Point(180, 374);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 2;
this.button2.Text = "button2";
this.button2.UseVisualStyleBackColor = true;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(897, 455);
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit();
this.ResumeLayout(false);
}

private void Button2_Click(object sender, EventArgs e)
{
if (_durationDisplay > 1)
{
_durationDisplay = 1;
_incFactor = 1;
}
else
{
_durationDisplay = 10;
_incFactor = 4;
}

}

private void Button1_Click(object sender, EventArgs e)
{
if (_samplingRate == 100)
_samplingRate = 500;
else
_samplingRate = 100;

}

private void Form1_Load(object sender, EventArgs e)
{
}

{
this.chart1.Series.Clear();

double[] data = new double[_samplingRate * _incFactor];

for (int i = 0; i < data.Length; i++)
data[i] = Math.Sin(2 * Math.PI * (i * _durationDisplay) / (_samplingRate * _incFactor)) * _amplitude;

Series d = new Series();
for (int i = 0; i < data.Length; i++)

}
}```

Here the results of sampling rate = 500, duration 1 sec and the second image 10 sec:

Regards,

Thorsten

Friday, May 5, 2017 6:06 AM
• What is the resolution of a screen?

If a screen can only show 1000 points, I need to convert 15,000 points to 1000 points, how to extract the data from the list,

Shown on the chart?

• Edited by Saturday, May 6, 2017 8:17 AM
Saturday, May 6, 2017 8:15 AM

Saturday, May 6, 2017 8:25 AM

• Hi lctk,

>>If a screen can only show 1000 points, I need to convert 15,000 points to 1000 points, how to extract the data from the list,

You may calculate the interval in each waveform range, and then calculate about 1000 points. This ensures the shape will not change.