我張貼含有math.stackexchange.com的這只是數學部分類似的問題,而這個答案解決了這個問題:
math.stackexchange.com/a/232124/27435
在任何情況下,將來有類似的問題,這裏是幾乎字面SciPy的實現,它的答案(第一行是初始化樣板代碼):
import numpy
import scipy.linalg
### Origin of the coordinate system: upper left corner!
"""
1----------2
| |
| |
4----------3
"""
platform_width = 600
platform_height = 400
# positions of each load cell (one per corner)
loadcell_positions = numpy.array([[0, 0],
[platform_width, 0],
[platform_width, platform_height],
[0, platform_height]])
platform_origin = numpy.array([platform_width, platform_height]) * 0.5
# applying a known force at known positions and taking the measurements
measurements_per_axis = 5
total_load = 50
results = []
for x in numpy.linspace(0, platform_width, measurements_per_axis):
for y in numpy.linspace(0, platform_height, measurements_per_axis):
position = numpy.array([x,y])
for loadpos in loadcell_positions:
moments = platform_origin-loadpos * total_load
load = numpy.array([total_load])
result = numpy.hstack([load, moments])
results.append(result)
results = numpy.array(results)
noise = numpy.random.rand(*results.shape) - 0.5
measurements = results + noise
# now expand ("stuff") the 3x3 matrix to get a linearly independent 3x3 matrix
expands = []
for n in xrange(measurements.shape[0]):
k = results[n,:]
m = measurements[n,:]
expand = numpy.zeros((3,9))
expand[0,0:3] = m
expand[1,3:6] = m
expand[2,6:9] = m
expands.append(expand)
expands = numpy.vstack(expands)
# perform the actual regression
C = scipy.linalg.lstsq(expands, measurements.reshape((-1,1)))
C = numpy.array(C[0]).reshape((3,3))
# the result with pure noise (not actual coupling) should be
# very close to a 3x3 identity matrix (and is!)
print C
希望這可以幫助別人!
如果我理解正確,你想有一個解決**變量**(Fz,Mx,My)的每個**值的3變量方程?如果Fz,Mx和My用6位編碼(等於128個值),那麼給你大約一百萬個3x3矩陣來存儲.. – lucasg
@georgesl我在math.stackexchange.com上發佈了一個類似的問題,其中只包含了這個數學部分,和這個答案解決了這個問題:http://math.stackexchange.com/a/232124/27435 – heltonbiker
在這種情況下,你應該anwser你自己的問題,並關閉線程 – lucasg