矩阵操作
from numpy import *
V = mat([xd,yd,zd])
V = V.T
V = V.I
print(diag([1,2,2,1]))
解方程
from sympy import solve
from sympy.core.symbol import symbols
a0,a1,a2,a3,a4... = sympy.symbols('a0 a1 a2 a3 a4...')
A = a0 - 20
B = a1 - 0
C = a2 - 0
D = a0 + a1 + a2 + a3 + a4 - 60
result = sympy.solve([A,B,C,D...],[a0,a1,a2,a3,a4...])
theta1 = float(result[a0])
for value in result.values():
print(float(value))
绘图
import matplotlib.pyplot as plt
import numpy as np
xs = 2
ys = 6
xf = 12
yf = 3
x = np.linspace(xs,xf,11)
y = (yf-ys)/(xf-xs)*(x-xf)+yf
J1 = [2.14,-6.79,-14.6,-21.1,-26.1,-29.7,-32.2,-33.6,-34 ,-33.7,-32.6]
J2 = [139,138 ,136 ,133 ,129 ,125 ,120 ,114 ,108 ,101 ,93.2]
plt.plot(x,J1)
plt.plot(x,J2)
plt.show()