Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using PCI8616card;
- using System;
- using System.Windows.Forms;
- public class Util
- {
- public static double[] average(double[,] data)
- {
- int len = data.GetLength(0);
- int lines = data.Length/len;
- double[] result = new double[len];
- for(int i = 0; i < lines; i++)
- {
- for(int j = 0; j < len; j++)
- {
- result[j] += data[i, j];
- }
- }
- for (int j = 0; j < len; j++)
- {
- result[j] /= lines;
- }
- return result;
- }
- public static void writeData(double[] data, int skipSamples)
- {
- SaveFileDialog saveFileDialog = new SaveFileDialog();
- saveFileDialog.Title = "name of file to save";
- saveFileDialog.Filter = "文本文件(*.txt)|数据文件(*.dat)";
- saveFileDialog.FilterIndex = 1;
- saveFileDialog.OverwritePrompt = true;
- if (saveFileDialog.ShowDialog() == DialogResult.OK)
- {
- //获得文件路径
- string filePath = saveFileDialog.FileName.ToString();
- System.IO.StreamWriter objFile = new System.IO.StreamWriter(filePath);
- int len = data.GetLength(0);
- for (int j = skipSamples-1; j < len; j++)
- {
- objFile.WriteLine(Convert.ToString(data[j]));
- }
- objFile.Close();
- objFile.Dispose();
- MessageBox.Show("保存成功!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement