1 year ago

#180808

test-img

lmixa

Linspace give not exact float

I am trying to define a time vector which is evenly spaced with the numpy linspace function. It looks as following:

t_start = 0
t_end = 0.0032768 # in seconds, equals 3.2768ms
samples = 32768
time = np.linspace(t_start, t_end, samples, endpoint=False)

It produces an evenly spaced vector when opening the variable explorer. When I use indexing it produces this though:

In: time[100]
Out: 9.999999999999999e-06

I would like to get exactly 10e-6 instead of this odd number.

How can I handle this?

python

arrays

numpy

linspace

0 Answers

Your Answer

Accepted video resources