-2

I have a function which takes a dictionary and returns an acceleration a.

I put a list of data for a certain parameter (lets call it alpha) in that dictionary, and the function returned an array of 100 results(in respect to alpha).

Now I want to integrate these values one by one, to get let's say an array velocity v in respect to the parameter alpha ( so that i can plot these values in matplotlib).

Edit:

Actually i have a mechanical problem. The ladder is placed against the wall, and because its friction coefficient is too small it's starts sliding. So i have written a function which returns the acceleration of that ladder for any angle between 30° and 90°(30 is the starting angle, and 90 is when the ladder is on the ground).

Anyways, I've calculated acceleration in respect to the angle alpha. I have the data stored in array a. I tried scipy.integrate.simps() but that method returns the final velocity v. I've also tried scipy.integrate.quad() but returns the same result.

I would like to generate an array of velocities v which will contain a value for every angle, like in array of accelerations - a

talonmies
  • 70,661
  • 34
  • 192
  • 269
Beginner
  • 11
  • 3
  • 5
    That is interesting, but do you have an actual *question* you could like a answer to? – talonmies Jan 03 '16 at 14:31
  • Yeah, i don't now how to integrate that function properly – Beginner Jan 03 '16 at 14:39
  • 2
    That's not actually a question... Please take the [tour] and read [ask]. – jonrsharpe Jan 03 '16 at 14:41
  • I'm sorry, but you are going to have to explain much more clearly what your question is. For example, when you say "integrate", do you mean you want to perform symbolic integration, or numerical quadrature? If you have a numpy array, have you tried any of the `scipy.integrate` functions? If so, what went wrong? There are talented people here, but they can't read minds or look over your shoulder to see what your want to know. You have to tell us clearly what your question is. – talonmies Jan 03 '16 at 14:51
  • Some code would help as well :) – marw Jan 03 '16 at 16:02

1 Answers1

0

It sounds like you want to perform cumulative quadrature on an array of values. In that case, scipy.integrate.cumtrapz should do want you want. That will perform a cumulative integration using the trapezoidal rule on the supplied array, yielding an array of outputs the same size in the inputs. You control in initial value via a separate argument if it is non-zero.

talonmies
  • 70,661
  • 34
  • 192
  • 269