Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.IO;
- namespace WindowsFormsApp6
- {
- public partial class Form1 : Form
- {
- double firstX, firstY, secondX, secondY, thirdX, thirdY, rw, cl = 0.0;
- int count = 0;
- string x = "";
- string y = "";
- byte MinMax = 0; //0 equals rising, 1 equals falling
- //double Max = new Array[];
- //double Min = new Array[];
- private void button2_Click(object sender, EventArgs e)
- {
- Application.Exit();
- }
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- using (var reader = new StreamReader(@"D:data.csv"))
- {
- List<string> listA = new List<string>();
- List<string> listB = new List<string>();
- //List<int> peakIndexes;
- //List<int> valleyIndexes;
- while (!reader.EndOfStream)
- {
- var line = reader.ReadLine();
- var values = line.Split(',');
- listA.Add(values[0]); //contains all the x coords
- listB.Add(values[1]); //contains all the y coords
- //peakIndexes = new List<int>();
- //valleyIndexes = new List<int>();
- //string[] xPoints = listA.ToArray();
- //string[] yPoints = listB.ToArray();
- //listBox1.Items.Add(values[0]);
- //listBox2.Items.Add(values[1]);
- }
- }
- }
- public void GetValleysAndPeaks(double[] yValues, out List<int> peakIndexes, out List<int> valleyIndexes)
- {
- peakIndexes = new List<int>();
- valleyIndexes = new List<int>();
- bool directionUp = yValues[0] <= yValues[1];
- for (int i = 1; i < yValues.Length - 1; i++)
- {
- if (directionUp && yValues[i + 1] < yValues[i])
- {
- peakIndexes.Add(i);
- directionUp = false;
- }
- else if (!directionUp && yValues[i + 1] > yValues[i])
- {
- valleyIndexes.Add(i);
- directionUp = true;
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment