Home > Enterprise >  How to fix error "undefined variable:sin" in plotting in gnuplot?
How to fix error "undefined variable:sin" in plotting in gnuplot?

Time:08-10

I am plotting in 2D on gnuplot through Ubuntu. When defining my equation for 'radius of curvature' a function of theta=x of variables sin and cos functions, respectively, I get an error message saying 'undefined variable: sin' or cos. I am simply defining the variable R=1 in the equation then setting

f(x) = R*sin(x)*(1 4*cos**2*(x)**(1.5)) / 2*(2*sin**2*(x) 3*cos**2*(x))

then saying plot f(x). What am I doing wrong?

CodePudding user response:

With your function

f(x) = R*sin(x)*(1 4*cos**2*(x)**(1.5)) / 2*(2*sin**2*(x) 3*cos**2*(x))

you should actually get an error undefined variable: cos,

Your intention probably was:

f(x) = R*sin(x)*(1 4*cos(x)**2**(1.5)) / 2*(2*sin(x)**2 3*cos(x)**2)

or maybe

f(x) = R*sin(x)*(1 4*cos(x)**2**(1.5)) / (2*(2*sin(x)**2 3*cos(x)**2))

where I'm not sure whether in the first part this should really be: cos(x)**2**1.5

or maybe: R*sin(x)*(1 4*cos(x)**2)**1.5

Mind the parentheses.

  • Related