1

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
3
  • 1
    Is using echo in `echo ${INFILE}` and `echo ${INFILE}` necessary? Why don't you just incorporate the variable by itself? Commented May 10, 2012 at 10:41
  • It's not clear what you're looking for - i is your loop iteration variable. Is that the same as the i in the multiplication (SPEED * i)? Commented May 10, 2012 at 10:44
  • Yes, I want to replace i from multiplication by i value from loop Commented May 10, 2012 at 10:52

1 Answer 1

2

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
Sign up to request clarification or add additional context in comments.

1 Comment

@shelter There's also plot iteration in gnuplot 4.3+, but I think that would have a different result (it would put all the plots on the same graph) as opposed to having each of the plots in their own graph.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.