I am trying to pass a variable name into a function to include in a command. I want a function that can, for example:
eq=3*x^2+x
int_test(eq,x)
such that it can integrate the equation stored in eq by x. yielding:
int(3*x^2+x,x)
i can't get it to stop doing this:
int(3^x^2+x,<the variable name in the program>)
Matt
How to pass variable name to function in program
Modérateur : xcasadmin
-
- Messages : 146
- Inscription : mer. janv. 13, 2010 3:20 pm
Re: How to pass variable name to function in program
I'm confused. Perhaps you just need to quote the variable name '('x' instead of x)?
-
- Messages : 146
- Inscription : mer. janv. 13, 2010 3:20 pm
Re: How to pass variable name to function in program
I discovered:
eq:=-1/18*L^2*w+5/9*L*w*x-1/2*w*x^2
ind_var:=x
eval(expr(int,eq,ind_var))
works
eq:=-1/18*L^2*w+5/9*L*w*x-1/2*w*x^2
ind_var:=x
eval(expr(int,eq,ind_var))
works