I am trying to set the values of array elements to 0 in a numpy array +/- 50 from a certain index. I have a numpy array named proc_ranges
and I am using numpy.put()
to do this:
proc_ranges = numpy.put(proc_ranges,[closest_point_index-50:closest_point_index+50], 0)
I am getting a syntax error at the ":", but this seems like the correct way to do this according to the syntax outlined here
You could just do this instead
proc_ranges[closest_point_index-50:closest_point_index+50] = 0
Yeah, you just need to make sure that the value closest_point_index-50
or closest_point_index+50
do not exceed the array size.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.