曲面/线 拟合gnuplot
1. 下载gnuplot windows 版,安装,(别的绿色的可能下载即用,推荐下面链接这款)
gnuplot - Browse Files at SourceForge.net
2. 准备数据,存成data.dat或者其它文件名称,放桌面
数据内容如下(x, y, z; 每行一个三维空间中的一个点,中间空格隔开):
-10 9.8 0.001903262
10 11.5 -33.86808898
25 25.01 -60.41089557
40 41 -86.618
3. 打开gnuplot
依次运行:
gnuplot> f(x,y) = a + b*x + c*y + d*x*y
gnuplot> a=0.06;b = -1;c = -1;d = 0.01
gnuplot> fit f(x,y) 'data.dat' using 1:2:3 via a,b,c,d
得到如下输出:
执行如下指令,并得到输出:
gnuplot> print sprintf("????????: z = %.6g + %.6g*x + %.6g*y + %.6g*x*y", a, b, c, d)
拟合函数: z = -15.5526 + -1.69632*x + -0.130664*y + 0.00130773*x*y
(注:我的Gnuplot中,可能汉字字符编码问题,显示为问号如上“???。。。。“),尽管输入汉字,输出可以显示中文)
gnuplot> set terminal wxt size 800,600 enhanced
Terminal type is now 'wxt'
Options are '0 size 800, 600 enhanced'
gnuplot> set xlabel "x"; set ylabel "y"; set zlabel "z"; set title "拟合曲线及数据"
gnuplot> set style data lines;set pm3d at s hidden3d # ??????????set grid x y z
gnuplot> set isosamples 40, 40;set samples 40
gnuplot> set view 60, 45
gnuplot> splot f(x,y) title '拟合曲面', 'data.dat' using 1:2:3 with points pt 7 ps 2 lc rgb "red" title '数据点'
(上面如果执行有问题,手敲进去,英文字符模式)
附: gnuplot homepage 学习网站 及资料链接
Gnuplot的使用技巧