toylas
toylas

Reputation: 437

Using variables in gnuplot binary file plotting

I am plotting direct access binary files output from my simulations using gnuplot and want to write a simple generic script that will plot the files without me having to edit the file a lot. Here is what I want to do:

nx=real(system(sprintf("command to find nx")))
dx=real(system(sprintf("command to find dx")))
plot 'Fvy.dat' binary format="%double" record=nx skip=0*nx u ($0*dx):1 w l t '{/Symbol d}vy'
similar plotting multiple times

Now the problem is that the above command gives me an error

gnuplot> plot 'Fvy.dat' binary format="%double" record=nx skip=0*nx u ($0*0.025):1 w l t '{/Symbol d}vy'
                                                   ^
     ';' expected

If I use the number directly, e.g.

plot 'Fvy.dat' binary format="%double" record=128 skip=0*nx u ($0*dx):1 w l t '{/Symbol d}vy'

it works fine. The only place where the trouble lies is the record command. skip command takes nx as an argument easily. Does anyone have an idea how to make record accept a variable?

Thanks!

Upvotes: 0

Views: 1484

Answers (1)

Tobias Müller
Tobias Müller

Reputation: 605

Put parentheses around nx:

plot 'Fvy.dat' binary format="%double" record=(nx) skip=0*nx u ($0*0.025):1 w l t '{/Symbol d}vy'

Upvotes: 1

Related Questions