bash: loading presaved variable to gnuplot cmd load

吃可爱长大的小学妹 提交于 2019-12-13 17:25:18

问题


My intention is to have loaded variable i in for cycle - I want to have it usable for this cycle. Current state is that gnuplot loads var i from the first echo as a string not var.

SPEED=5

echo "plot '< head -n \"\$((SPEED*i))\" `echo ${INFILE}`' using 1:3 ;">> file.plt

for ((i=1;i<="$FRAMES";i++))                                     
do      
    echo  " 
        load '`echo ${file.plt}`';  
        " | gnuplot
done

回答1:


I think you can probably do all of this in gnuplot directly...

if(! exists("N")) N=0
FRAMES=10
FILE='myfile.plt'
SPEED=5
f(i)=sprintf("< head -n %d ".FILE,i+SPEED)
plot f(N) using 1:3
if(N < FRAMES) N=N+1
if(N < FRAMES) reread

Gnuplot 4.6 makes this even easier:

do for [N=1:10]{
   FILE='myfile.plt'
   SPEED=5
   f(i)=sprintf("< head -n %d ".FILE,i+SPEED)
   plot f(N) using 1:3

}


and instead of using head, you can probably use the every datafile modifier (help every for details). I think something like the following:

NPT=N+SPEED
plot FILE every ::::NPT using 1:3


来源:https://stackoverflow.com/questions/10532168/bash-loading-presaved-variable-to-gnuplot-cmd-load

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!