I'm trying to be able to create symbols for a DH table, but rather that write it out, create a function. However, I don't know how to call the variable when making the table. Here is a synopsis of the problem:
from sympy import *
def naming_symbols(N):
theta = symbols(f"theta:{N}")
L = symbols(f"L:{N}")
alpha=symbols(f"alpha:{N}")
d=symbols(f"d:{N}")
pprint(theta[:])
pprint(L[:])
pprint(alpha[:])
pprint(d[:])
return theta, L, alpha, d
naming_symbols(3)
print(theta2)
returns:
"*FileName*", line 18, in <module>
print(theta2)
NameError: name 'theta2' is not defined
(θ₀, θ₁, θ₂)
(L₀, L₁, L₂)
(α₀, α₁, α₂)
(d₀, d₁, d₂)
Process finished with exit code 1
This is the same for "theta_2" and "theta"
How do I call the created symbols? As in, I want to put "theta2" in the table, but it doesn't recognize it as a created symbol. I think I need to add the symbols into a dictionary or something, but don't know how to do that either. I thought the creation would add it to the dictionary... but... well, please help.
Read more here: https://stackoverflow.com/questions/66999197/sympy-call-symbols-created-using-a-range
Content Attribution
This content was originally published by Manju at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.