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的使用技巧