如何从 np.array 获取积分值?
我正在尝试从 np.array 值列表中获取积分值。不是函数下的表面,而是值。我有加速度值并且想要获得速度值。 假设我有一个像这样的数组:
a_x = np.array([111.2, 323.2, 123.3, 99.38, 65.23, -0.19, -34.67])
我尝试从该数组中获取积分值以获取速度值。
如果我使用 simps、quad、trapz,我会得到一个数字(表面)。
那么如何整合 np.array 值并获得可以存储在列表中的整合值?
I am trying to get integrated values from np.array, list of values. Not the surface under the function, but values. I have values of acceleration and want to get values of velocity.
So let's say I have an arry like:
a_x = np.array([111.2, 323.2, 123.3, 99.38, 65.23, -0.19, -34.67])
And I try to get integrated values from this array to get the values of velocity.
If I use lets say simps, quad, trapz, I get the one number (surface).
So how do you integrate np.array values and get integrated values that you can store in a list?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你无法按照你想要的方式去做,因为你不了解其背后的流程。如果给定加速度,则使用以下等式:
你只能求不定积分,你知道加速度,但你不知道起始条件,因此你的解决方案不能空的。
由于每个问题的解决方案是:“计算给定加速度的速度”,那么解决方案将是 v(t)=a(t)dt+c 的积分,其中加速度是恒定的,因此它不依赖在 t 上,它可以写为 v(t)=at+c,但是我们仍然不知道加速持续了多长时间以及起始条件是什么。
但是回答有关获取可以存储在列表中的值的问题 - 您可以通过索引 np.array 的值来完成此操作:
因为quad、simps或trapz是用于给定点的方法,它们使用相应的方法返回那些给定点的积分值,例如:
如果未指定x(如您的情况),则假定您要使用梯形估计给定点的 y 值下的场,其中 x 等于 x 的分布。它必须赋予一个值。
You can't do it by the way you want it, because you didn't understand the process behind it. If you are given acceleration, then using the following equation:
You are able only to find INDEFINITE integral, you know the acceleration, but you don't know starting conditions, thus your solution can't be empty.
As the solution to each of those questions is: "Find velocity given an acceleration", then the solution would be v(t)=integral of a(t)dt+c, where your acceleration is constant, so it doesn't rely on t and it can be written as v(t)=at+c, but still - we don't know anything about how long acceleration lasted and what is the starting condition.
But answering the question about getting values which can be stored in a list - you do it by indexing your values of np.array:
Because quad,simps,or trapz are methods used for given points, which return value of integral with those given points with corresponding method, for example:
if x isn't specified (as in your case), it assumes that you want to use trapeze to estimate the field under the value y of given points with x equal distribution of x. It has to give one value.