Pengurutan Matrix dengan Python

from numpy import *

propagationSpeed = 34300;
xrand = random.randint(-200,200);
yrand = random.randint(-200,200);
sourcePos = (xrand,yrand);
# sourcePos = (0,0);

 

sensorPos = matrix(‘200 0;0 200;-200 0;0 -200’)

distance = matrix(‘0;0;0;0’)

for sensorNum in range(0,4):
distance[sensorNum] = linalg.norm(sourcePos – sensorPos[sensorNum,])

sensorTOA = distance/propagationSpeed;

sortedTDOA = zeros((6,3));

a = 0;

for i in range(0,3):
for j in range(i+1,4):
sortedTDOA[a,0]=abs(sensorTOA[i]-sensorTOA[j]);
sortedTDOA[a,1]= i;
sortedTDOA[a,2]= j;
a = a + 1

print(sortedTDOA);

#sortedTDOA = sortedTDOA.argsort(axis=1)
#sortedTDOA[:,sortedTDOA[0,:].argsort()]
indeks = argsort(sortedTDOA[:,0])
sortedTDOA = sortedTDOA[indeks]

print(sortedTDOA);

Leave a Reply

Your email address will not be published. Required fields are marked *