+ 8

How do we write this kind of code in python, not to get errors ? I mean in this matrix there are variable values are not given.

This kind of code works in octave. T01=matrix('cos(t1), -sin(t1), 0, a0; sin(t1)*cos(alf0), cos(t1)*cos(alf0), -sin(alf0), -sin(alf0)*d1; sin(t1)*sin(alf0), cos(t1)*sin(alf0), cos(alf0), cos(alf0)*d1;0, 0, 0, 1'); The errors are: Traceback (most recent call last): File "/home/zhenis/Downloads/ExampleVectors.py", line 21, in <module> T01=matrix(double('cos(t1), -sin(t1), 0, a0; sin(t1)*cos(alf0), cos(t1)*cos(alf0), -sin(alf0), -sin(alf0)*d1; sin(t1)*sin(alf0), cos(t1)*sin(alf0), cos(alf0), cos(alf0)*d1;0, 0, 0, 1')); ValueError: could not convert string to float: cos(t1), -sin(t1), 0, a0; sin(t1)*cos(alf0), cos(t1)*cos(alf0), -sin(alf0), -sin(alf0)*d1; sin(t1)*sin(alf0), cos(t1)*sin(alf0), cos(alf0), cos(alf0)*d1;0, 0, 0, 1

15th Feb 2019, 9:09 PM
Zhenis Otarbay
Zhenis Otarbay - avatar
2 odpowiedzi
+ 2
Try rewriting the parameters in bracketed form instead of string. Then it works for me. https://code.sololearn.com/c0LjAWwp1p9c/?ref=app
16th Feb 2019, 5:22 AM
Tibor Santa
Tibor Santa - avatar
+ 9
Please include code from code playground.
16th Feb 2019, 2:03 AM
Hubert Dudek
Hubert Dudek - avatar