2015-05-19 70 views
3

Here該OP定義了功能round,功能floorgnuplot中。幫助floor說:如何在gnuplot中使用floor功能

gnuplot> help floor 
The `floor(x)` function returns the largest integer not greater than its 
argument. For complex numbers, `floor` returns the largest integer not 
greater than the real part of its argument. 

如何使用floor我所做的:

gnuplot> floor(7.3) 
     ^
     invalid command 

我可以以某種方式改變,其數量將四捨五入到小數位的數量?

+1

請閱讀你lin的問題k再次。作者將他自己的「round」函數定義爲round(x)= x - floor(x)<0.5? floor(x):ceil(x)'。要用gnuplot測試某些東西,你必須'印刷地板(7)'。 – Christoph

+0

哦,我明白了,謝謝。我將編輯關於'floor'使用的問題。 –

回答

5

要查看或打印功能調用的結果,你必須明確地print

gnuplot> print floor(7.3) 
7 

要修改鏈接round功能僅在一些小數位四捨五入,請使用以下

round(x) = x - floor(x) < 0.5 ? floor(x) : ceil(x) 
round2(x, n) = round(x*10**n)*10.0**(-n) 

並稱之爲

gnuplot> print round2(7.3456, 1) 
7.3 
gnuplot> print round2(7.3456, 2) 
7.35 
+0

非常感謝 –