2015-06-06 28 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」是不是有效的格式字符串,那麼你會得到一個錯誤。