0

I have to prepare my data for animation and I ran across a problem

t = numpy.linspace(0, 1/10, 1/10000)
x = [1, 3, 5, 7, 9]
S = [ 0.09642699 -1.75110819 -0.00915477 -0.42833324 -0.01772692 -0.00885592
 -0.01136874  0.4106214   0.09199903  1.73339635]
realResponse = [x * numpy.cos(311.64*t) for x in numpy.dot(eigenvector, modalconstant)]
#realResponse = numpy.delete(realResponse, my_list, axis=0)

Now this realResponse list turns out to be... well.. nothing

    print(realResponse)# prints: [array([], dtype=float64), 
                                  array([], dtype=float64), array([], dtype=float64),....

I don't know what seems to be the problem. I carefully followed this topic.

Anyway I also tried

realResponse = list()
for i in range(0, 10):
    realResponse[i] = S[i] * numpy.cos(eigenvalue[311.64*t)

and turns out to be an error:

IndexError: list assignment index out of range

Community
  • 1
  • 1
skrat
  • 648
  • 2
  • 10
  • 27
  • 1
    What is the error? And also, `t` is not one value! – Aidin Nov 03 '16 at 10:55
  • @Aidin: IndexError: list assignment index out of range – skrat Nov 03 '16 at 10:56
  • And yes. `t` is supposed to be a variable (time). I still have to figure out how to prepare my data correctly, it is my first time doing animations in python. – skrat Nov 03 '16 at 10:59
  • I don't know python very well, but don't you need to do this for every `t` value like in a loop rather than just inserting `t`? I mean, right now you have two variables that changes, `x` and `t` – Aidin Nov 03 '16 at 11:00
  • Are you expecting `realResponse` to be a matrix? – Aidin Nov 03 '16 at 11:04
  • @Aidin: No, `realResponse` should be a vector of time-dependant y coordinates, while the x coordinates are stationary. :) I still need to work a bit more with code, yes. That didn't solve my problem but Xirtaminu for sure answered my question. – skrat Nov 03 '16 at 11:07
  • Ok, because to me it looks like you are trying to evaluate `x` in every timeframe and then move to the next `x` to evaluate for every time, hence resulting in a 2D matrix of `x` and `t` – Aidin Nov 03 '16 at 11:09

1 Answers1

3

numpy.linspace(0, 1/10., 1/10000.)

returns an empty array. If you want an array between 1/10 with points every 1/10000 try:

numpy.arange(0, 1/10., 1/10000.)

Xirtaminu
  • 404
  • 2
  • 5