turning a string into an equation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phoenix1990
    New Member
    • May 2009
    • 18

    turning a string into an equation

    so i have an entry frame where i want to input an equation, and i need to turn the string into an actual equation in terms of x. so that i can plot it on a canvas.
    i already know how to make the entry frame, and how to extract the string equation that was inputed.
    the only problem i'm having is converting it into an actual equation.
    e.g.
    the string input is 'sin(x)'
    and i want to turn it into sin(x)
    x is defined by another entry frame which will indicate the number of steps between two boundaries.
    say the boundary was [-10, 10]
    and the number of steps was set to 40
    therefore x will be equal to [-10:0.5:10]

    so i was thinking that i should define the values for x first using a simple loop, and then convert 'sin(x)' into an equation.

    everything is pretty easy besides the conversion.
    any help is appreciated
    thanks
    phoenix1990
  • Glenton
    Recognized Expert Contributor
    • Nov 2008
    • 391

    #2
    Actually everything including the conversion is pretty easy. This is one of python's strengths! Check out the eval() command.

    Comment

    • phoenix1990
      New Member
      • May 2009
      • 18

      #3
      thanks for the help Glenton.
      it worked like a charm.

      Comment

      Working...