Matrix Problem - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: Matrix Problem (/thread-2728.html) |
Matrix Problem - Salito - Apr-05-2017 Hi everyone, I'm a beginner in Python language and I've got a little problem with a matrix I tried to encode. I want to have these vectors : [[ 0 ] [ - l*cos(q_tri[:,1]) ] [ - l*cos(q_tri[:,1]) - l*cos(q_tri[:,2]) ] [ - l*cos(q_tri[:,1]) - l*cos(q_tri[:,2]) - l*cos(q_tri[:,3]) ] [ - l*cos(q_tri[:,1]) - l*cos(q_tri[:,2]) - l*cos(q_tri[:,3]) - l*cos(q_tri[:,4]) ]] for Yn[] and [[ 0 ] [ l*sin(q_tri[:,1]) ] [ l*sin(q_tri[:,1]) + l*sin(q_tri[:,2]) ] [ l*sin(q_tri[:,1]) + l*sin(q_tri[:,2]) + l*sin(q_tri[:,3]) ] [ l*sin(q_tri[:,1]) + l*sin(q_tri[:,2]) + l*sin(q_tri[:,3]) + l*sin(q_tri[:,4]) ]] for Xn[]But I couldn't be successful ... Here what I tried to do : Xn = [0] for a in range (0,n): Xn.append(L*np.sin(q_tri[:,a])) Yn = [0] for b in range (0,n): Yn.append(-L*np.cos(q_tri[:,b]))Here q_tri[] is of size n. I also tried two for loops but it didn't work either. Thank you for the time you'll pass on it, I know it would'nt be that hard RE: Matrix Problem - zivoni - Apr-05-2017 I am not sure what do you exactly want and what is shape of q_tri. If its just array with (1, 5) shape, then perhaps adding sum into your for loop will do it.
|