2015-06-06 24 views
1

我母语非英语,所以对不起,我英文不好。gnuplot的错误:“坏格式字符”,尽管“设置数据文件分隔符”

我使用的gnuplot 5.0.0 MacOSX上并执行下一个代码。

plot "psd.dat" using 1:2 

和我psd.dat文件的内容如下:

-500 14.51 15.12 
-450 14.54 15.08 
-400 14.57 15.04 
-350 14.59 15.02 
-300 14.60 14.96 
-250 14.66 14.95 
-150 14.71 14.90 
-100 14.76 14.87 
-50 14.79 14.83 
0 14.85 14.85 
50 14.84 14.78 
100 14.89 14.74 
150 14.93 14.72 
200 14.98 14.70 
250 15.02 14.68 
300 15.05 14.66 
350 15.12 14.64 
400 15.16 14.63 
450 15.21 14.62 
500 15.26 14.60 

但我有个错误。

Bad format character 

我提到gnuplot error: Bad format character | stackoverflow和执行:

set datafile separator whitespace 

但即使我执行它,我也有“坏格式字符”错误。 我想我所做的是非常基本的,所以我不知道为什么我有这个错误。 你有什么想法解决它吗?请告诉我。

P.S. 我解决了这个错误后,我想执行下一个代码。

set autoscale fix 
set format x "%d" 
set format y "%.1f" 
f(x) = a*x+b 
a = 50000 
b = 0 
fit [-500:500] f(x) "psd.dat" using 1:(($2 - $3)/($2 + $3)) via a,b 
plot "psd.dat" using 1:(($2 - $3)/($2 + $3)*a+b) w p, f(x) 
set terminal tikz 
set output "psd.tex" 
replot 
set terminal pdf 
set output "psd.pdf" 
replot 
set terminal aqua 
+1

格式字符串“%d”在脚本的第二行是坏的。你的数据或数据文件分隔符没有错。检查“帮助格式说明符”。 – Karl

+0

顺便说一句,你不应该给一个适合参数一个零的起始值。像你这样的线性函数无论如何都会收敛,但这对于更复杂的拟合可能会出错。 – Karl

回答

0

它与您的数据无关。当你进入他们(与set format

gnuplot的不评估格式字符串,但只有当接下来的情节制成。

“%d”是不是有效的格式字符串,那么你会得到一个错误。