Give a number for Variable - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Give a number for Variable (/thread-36234.html) |
Give a number for Variable - quest - Jan-31-2022 I defined symbols via Sympy and I created an array. Then when I want to give a value to the variable, the variable still stay as variable. a, b, c, d = sympy.symbols('a b c d') error_mat=np.array([[a+d,b-c*1j],[b+c*1j,a-d]]) error_mat.shapeThen, after I found the correct values for my variables, I simply say that: a=0.9685 b=0.0315 print(error_mat) #error_mat.subs(a, 0.9685) #error_mat.subs(b, 0.0315)But my matrix is still: [[a + d b - 1.0*I*c] [b + 1.0*I*c a - d]]How can I update the variables? RE: Give a number for Variable - Larz60+ - Jan-31-2022 After line 2 in 2nd code set you need to re-run code error_mat=np.array([[a+d,b-c*1j],[b+c*1j,a-d]])
RE: Give a number for Variable - ibreeden - Jan-31-2022 Or else have a look at eval(). |