2015-01-16 59 views
0

我在我的大學裏爲gnuplot編寫了一個腳本,並將數據帶到了我家裏的電腦中。 下面是相關代碼:Gnuplot gprintf()在新電腦上不工作

set terminal postscript eps enhanced color font 'Helvetica,20'; 
set encoding utf8; 


do for[i=2:12] for[j in "3 4 6"]{ 

set autoscale x; 
set xr[-3:3]; 
set autoscale y; 
set key right bottom; 
set terminal postscript eps color ; 
set termoption dash; 


set xlabel "bla"; 
set ylabel "bla"; 

set output 'home/Plots/test-'.i.'-'.j.'.eps'; 

plot 'home/Daten/test-'.i.'-'.j.'.dat' with lines lw 4 title gprintf("homogen q=%.3f",(1/(j-1)-1/(10*(j-1)))/2); } 

的gprintf()犯規work..it只給了我0.00,但在我的UNI計算機它是正確的...幫助任何人:(

編輯: 我發現gnuplot的輪......當我在

gprintf("homogen q=%.3f",j) 

鍵入它給了我q=3爲J = 3.00

如果我使用:

gprintf("homogen q=%.3f",j/5) 

它給了我q=0.00

它必須與gnuplot..because一個問題,正如我所說的,在其他計算機上,它的工作:/

+0

你可能有整數除法,使用'1.0'等進行計算 – Christoph

+0

感謝前面回答:)我很新的GNUPLOT ...你是什麼意思與「使用1.0等等。' ? – Martin

+0

你是對的...如果我鍵入2/4它是零..如果我鍵入2.0/4它是0.5 ...但問題是,我不能這樣做爲j作爲一個變量...可以我改變它在gnuplotsettings本身? – Martin

回答

0

回答

使用

... gprintf("homogen q=%.3f",(1.0/(j-1.0)-1.0/(10.0*(j-1.0)))/2.0) 

循環變量默認是整數,gnuplot是在其使用整數運算,因爲你已經發現了相當字面...

建議未請求

作爲一個風格問題,我建議簡化個別生產線的標題q = ...和使用描述性的情節標題,例如,

Response curves for different values of the specific energy "q"

+0

感謝您的回答!我做了你所說的並且它工作正常!我仍然想知道爲什麼它在我的大學gnuplot版本中沒有'.0'的工作... – Martin

相關問題