首页 > 解决方案 > gnuplot 拟合扩展了分配的点。如何解决这个错误?

问题描述

我有 2 组数据文件

#veff   S   Pmax    S   Pmin
0.10    103 0.2135  152 -0.0505
0.11    104 0.2162  152 -0.0592
0.12    105 0.2177  152 -0.0669

#veff   S   Pmax    S   Pmin
0.13    106 0.2177  152 -0.0729
0.14    105 0.2162  152 -0.0778
0.15    105 0.2127  152 -0.0819
0.16    105 0.2078  152 -0.0858
0.17    105 0.2018  153 -0.0879
0.18    104 0.1959  153 -0.0889
0.19    104 0.1907  153 -0.0898
0.20    103 0.1860  153 -0.0921

虽然我尝试拟合拟合超出了代码的要点

set terminal wxt
#set term postscript eps color enhanced
#set output "1.eps"
set xlabel "Pmax"
set ylabel "Pmin"
[![enter image description here][1]][1]
set title "Pmax vs Pmin"
unset key

FIT_LIMIT = 1e-6
f1(x)=a1*x*x+b1*x+c1
f2(x)=a2*x*x+b2*x+c2

fit [x=0.185:0.218] f1(x)  "PmaxPminVEFF.txt" u 3:5 via a1,b1,c1 
fit [x=0.212:0.218] f2(x) "PmaxPminVEFF1.txt" u 3:5 via a2,b2,c2

plot 'PmaxPminVEFF.txt' using 3:5 with p pt 7,f1(x) lc rgb "red",\
    'PmaxPminVEFF1.txt' using 3:5 with p pt 8, f2(x) lc rgb "green"

拟合线超出点。帮我在这里修理配件。Fit 命令也不起作用。

在此处输入图像描述

标签: gnuplotgnuplot-iostream

解决方案


检查以下内容:

代码:

### Limit fitted plot to data
reset session

$Data1 <<EOD
#veff   S   Pmax    S   Pmin
0.13    106 0.2177  152 -0.0729
0.14    105 0.2162  152 -0.0778
0.15    105 0.2127  152 -0.0819
0.16    105 0.2078  152 -0.0858
0.17    105 0.2018  153 -0.0879
0.18    104 0.1959  153 -0.0889
0.19    104 0.1907  153 -0.0898
0.20    103 0.1860  153 -0.0921
EOD

$Data2 <<EOD
#veff   S   Pmax    S   Pmin
0.10    103 0.2135  152 -0.0505
0.11    104 0.2162  152 -0.0592
0.12    105 0.2177  152 -0.0669
EOD

set xlabel "Pmax"
set ylabel "Pmin"
set title "Pmax vs Pmin"
unset key

FIT_LIMIT = 1e-6
f1(x) = a1*x**2 + b1*x + c1
f2(x) = a2*x**2 + b2*x + c2

fit [x=0.185:0.218] f1(x) $Data1 u 3:5 via a1,b1,c1 
fit [x=0.212:0.218] f2(x) $Data2 u 3:5 via a2,b2,c2

plot $Data1 using 3:5 with p pt 7, \
     [x=0.185:0.218] f1(x) lc rgb "red",\
     $Data2 using 3:5 with p pt 8, \
     [x=0.212:0.218] f2(x) lc rgb "green"
### end of code

结果:

在此处输入图像描述


推荐阅读