Finding max value from an array ([[x1,y1],[x2,y2],[x3,y3]])

Viewed 13

I am trying to find max value of the above mention array. mad min value. The data is of vehicles present on the road. I am trying to find max accelration and deceleration at a time

1 Answers

I am assuming [x, y] is x and y axis acceleration. And by acceleration value, You mean sqrt(x^2 + y^2) value. Then, You can:

import numpy as np

accelerating_cars = [[1,1],[2,2],[3,3]]

index_min = np.argmin(list(map(lambda x: x[0]**2 + x[1]**2, accelerating_cars)))

For max in same way

Related