c# 读取txt并绘图

fwloveme 2010-11-05 12:42:15
现在又一个txt文件,里面存了几列采集到的数据,如下所示:

t(ms) S1x S1y S1 S2x S2y S2
1.72 4.47 -2.98 5.37 0.99 -0.99 1.40
....
...
..
.

其中,我想读取此文本的数据到picturebox里,横坐标为时间,纵坐标为s(信号),分别显示两条曲线s1和s2(其中,S1x和S1y分别为S1的横坐标点和纵坐标点),小弟现在无从下手,请高人指点,不胜感激!!!
...全文
499 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
renjunfeng 2010-11-12
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 fwloveme 的回复:]
6楼的哥么,怎么用AreaChart啊?
[/Quote]
http://code.google.com/intl/zh-CN/apis/visualization/documentation/gallery/areachart.html
fwloveme 2010-11-11
  • 打赏
  • 举报
回复
6楼的哥么,怎么用AreaChart啊?
renjunfeng 2010-11-11
  • 打赏
  • 举报
回复
用Jquery的 Jflot插件,或是用google 的AreaChart
tzysf 2010-11-11
  • 打赏
  • 举报
回复
参考zedgraph.
zhoujk 2010-11-11
  • 打赏
  • 举报
回复
s1x,s1y,s1Val , s2x,s2y,s2Val 对应的就是二维空间了,再加上一个时间轴,就是3D空间了。用灰度图是画不出来这些数据的
fwloveme 2010-11-10
  • 打赏
  • 举报
回复
没有高人指点啊
旅行者I号 2010-11-05
  • 打赏
  • 举报
回复

byte[] byData = new byte[1000];//长度自己看着办
char[] charData = new char[1000];
try
{
FileStream sFile = new FileStream("C:\\MeasureData.txt", FileMode.Open);
sFile.Seek(0, SeekOrigin.Begin);//设置第一个参数,把t(ms) S1x S1y S1 S2x S2y S2部分忽略掉
sFile.Read(byData, 0, 1000);
}
catch (IOException ex)
{
MessageBox.Show("error");
}
Decoder d = Encoding.UTF8.GetDecoder();
d.GetChars(byData, 0, byData.Length, charData, 0);
StringBuilder sbData = new StringBuilder();
foreach (char temp in charData)
{
sbData.Append(temp);
}
string strData = sbData.ToString();
MatchCollection mats = Regex.Matches(strData + " ", @"([^\s]*?)\s[^\s]*?\s[^\s]*?\s([^\s]*?)\s[^\s]*?\s[^\s]*?\s([^\s]*?)\s");
foreach (Match mat in mats)
{
string strTime = mat.Groups[1].ToString();
string strS1Value = mat.Groups[2].ToString();
string strS2Value = mat.Groups[3].ToString();
//将time,value记入到集合中(自己定义嘛,List<T>,或者直接Point[])
}

//Graphics g= this.CreateGraphics();
//g.DrawCurve(new Pen(),Point[] pts);

111,129

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧