none
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){

    }

    }


    please verify my account




    • Edited by lctk 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
    Moderator
  • 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
    Answerer
  • 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?

    please verify my account

    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

    please verify my account

    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
    Answerer
  • 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

    please verify my account

    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.Load += Form1_Load;
                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";
                this.chart1.ChartAreas.Add(chartArea1);
                legend1.Name = "Legend1";
                this.chart1.Legends.Add(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.Series.Add(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.Controls.Add(this.button2);
                this.Controls.Add(this.chart1);
                this.Controls.Add(this.button1);
                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)
                            d.Points.Add(_dataPoints[i]);
    
                        this.chart1.Series.Add(d);
                    }
                    else
                    {
                        this.chart1.Series.Clear();
                        Series d = new Series();
                        for (int i = 0; i < _dataPoints.Count; i++)
                            d.Points.Add(_dataPoints[i]);
    
                        this.chart1.Series.Add(d);
                    }
            }
    
            private void Button1_Click(object sender, EventArgs e)
            {
                if (_samplingRate == 100)
                    _samplingRate = 500;
                else
                    _samplingRate = 100;
    
                AddData();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                AddData();
            }
    
            private void AddData()
            {
                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++)
                    d.Points.Add(new DataPoint(i, data[i]));
    
                this.chart1.Series.Add(d);
            }
        }

    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


    please verify my account

    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.Load += Form1_Load;
                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";
                this.chart1.ChartAreas.Add(chartArea1);
                legend1.Name = "Legend1";
                this.chart1.Legends.Add(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.Series.Add(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.Controls.Add(this.button2);
                this.Controls.Add(this.chart1);
                this.Controls.Add(this.button1);
                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)
                            d.Points.Add(_dataPoints[i]);
    
                        this.chart1.Series.Add(d);
                    }
                    else
                    {
                        this.chart1.Series.Clear();
                        Series d = new Series();
                        for (int i = 0; i < _dataPoints.Count; i++)
                            d.Points.Add(_dataPoints[i]);
    
                        this.chart1.Series.Add(d);
                    }
            }
    
            private void Button1_Click(object sender, EventArgs e)
            {
                if (_samplingRate == 100)
                    _samplingRate = 500;
                else
                    _samplingRate = 100;
    
                AddData();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                AddData();
            }
    
            private void AddData()
            {
                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++)
                    d.Points.Add(new DataPoint(i, data[i]));
    
                this.chart1.Series.Add(d);
            }
        }

    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



    please verify my account

    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


    please verify my account

    Friday, May 5, 2017 4:33 AM

  • please verify my account

    Friday, May 5, 2017 4:33 AM

  • please verify my account

    Friday, May 5, 2017 4:35 AM

  • please verify my account

    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.Load += Form1_Load;
                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";
                this.chart1.ChartAreas.Add(chartArea1);
                legend1.Name = "Legend1";
                this.chart1.Legends.Add(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.Series.Add(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.Controls.Add(this.button2);
                this.Controls.Add(this.chart1);
                this.Controls.Add(this.button1);
                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;
    
                AddData();
            }
    
            private void Button1_Click(object sender, EventArgs e)
            {
                if (_samplingRate == 100)
                    _samplingRate = 500;
                else
                    _samplingRate = 100;
    
                AddData();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                AddData();
            }
    
            private void AddData()
            {
                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++)
                    d.Points.Add(new DataPoint(i, data[i]));
    
                this.chart1.Series.Add(d);
            }
        }

    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.Load += Form1_Load;
                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";
                this.chart1.ChartAreas.Add(chartArea1);
                legend1.Name = "Legend1";
                this.chart1.Legends.Add(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.Series.Add(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.Controls.Add(this.button2);
                this.Controls.Add(this.chart1);
                this.Controls.Add(this.button1);
                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;
                }
    
                AddData();
            }
    
            private void Button1_Click(object sender, EventArgs e)
            {
                if (_samplingRate == 100)
                    _samplingRate = 500;
                else
                    _samplingRate = 100;
    
                AddData();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                AddData();
            }
    
            private void AddData()
            {
                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++)
                    d.Points.Add(new DataPoint(i, data[i]));
    
                this.chart1.Series.Add(d);
            }
        }

    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?


    please verify my account


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

  • please verify my account

    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.

    If I have any misunderstanding, please upload your demo to OneDrive(Including your test material). We can download it and debugging. This will help us quickly analyze your problem.
    Share OneDrive files and folders:
    https://support.office.com/en-us/article/Share-OneDrive-files-and-folders-9fcc2f7d-de0c-4cec-93b0-a82024800c07


    Best Regards,

    Yohann Lu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, May 26, 2017 5:32 AM
    Moderator