Search code examples
gnuplot

Gnuplot: unset variable


Quite a basic question, I guess, but neither Google nor the docs helped me much so: is it possible to undefine variables? So that

a = 0
[some operation]
print(exists("a"))

results in 0 being printed.


Solution

  • What you are looking for is undefine:

    gnuplot> print a           
             undefined variable: a
    
    gnuplot> print(exists("a"))
    0
    gnuplot> a=10
    gnuplot> print a           
    10
    gnuplot> print(exists("a"))
    1
    gnuplot> undefine a
    gnuplot> print a           
             undefined variable: a
    
    gnuplot> print(exists("a"))
    0
    gnuplot>