问题
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