Issue
I'm new to Numpy. I have the following variables:
import numpy as np
arr = np.array([[3, 5, 9], [1, 2, 3]]).T
Dr = 2
Dl = 3
Db = 4
delta_R = arr[0, 0]
delta_L = arr[1, 0]
delta_B = arr[2, 0]
delta_theta = (delta_L - delta_R) / (Dr + Dl)
I'm attempting to implement the following equation:
To do so, I've written:
delta_x_delta_y_arr = np.array([2*np.sin(delta_theta/2) * np.array([(delta_B / delta_theta) + Db], [(delta_R / delta_theta) + Dr])])
Firstly, I'm not certain whether I've expressed this equation properly using Numpy arrays. If I have, why do I see the following traceback?
TypeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_5072/2142976421.py in <module>
----> 1 delta_x_delta_y_arr = np.array([2*np.sin(delta_theta/2) * np.array([(delta_B / delta_theta) + Db], [(delta_R / delta_theta) + Dr])])
TypeError: Field elements must be 2- or 3-tuples, got '9.5'
Thanks in advance for any assistance you can give this Numpy newbie!
Solution
The NumPy array should be np.array([[...], [...]])
rather than np.array([...], [...])
. Try
delta_x_delta_y_arr = 2*np.sin(delta_theta/2) * np.array([[(delta_B / delta_theta) + Db], [(delta_R / delta_theta) + Dr]])
instead.
Answered By - 7shoe
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.