필터 지우기
필터 지우기

How to numerically integrate a non-integer (using trapz)

조회 수: 2 (최근 30일)
Brian Peoples
Brian Peoples 2019년 4월 3일
답변: Walter Roberson 2019년 4월 3일
In this case im trying to get F(i) with the given inputs:
kp = -25
ki = 10
theta(i) = .314 or something thats not an integer
t = .01
F(i) = kp*theta(i) + ki.*trapz(t,theta(i))
This will not run because theta(i) is not an integer... I'm using radians that change in each iteration of a loop. Any ideas?
Regards,
Brian Peoples

답변 (1개)

Walter Roberson
Walter Roberson 2019년 4월 3일
When you use trapz() and supply a scalar second argument but no third argument, trapz() always interprets the argument as a dimension number. If you do not want it to be a dimension number then you must supply a third parameter containing the dimension number.
If you are trying to supply theta(i) as the spacing between points, then it would need to go as the first parameter.
Your likely mistake is in trying to call trapz() on one y point at a time. You should put all of the x and y into vectors first, and then use a single trapz() call.

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by