Intergrate a array over Tb?

조회 수: 1 (최근 30일)
Willim
Willim 2019년 4월 3일
댓글: Walter Roberson 2019년 4월 5일
If I have x=[0.2 1 0.485 0.13 0.11] , I have Tb=10ms and the fs=16*fb; %Sampling frequency
Ts=1/fs; I would like to integrate the x over Tb. How can I do it without using the integration functions. Using the summing algorithm.
  댓글 수: 3
Willim
Willim 2019년 4월 5일
integrationBase = 0:1/fs:Tb-1/fs;
for i = 0:(length(v)/(Tb*fs))-1,
y1(i+1)=trapz(integrationBase,v(int32(i*Tb*fs+1):int32((i+1)*Tb*fs)));
end
The summing algoithm I mean "summation of the discrate values on the array v"
Walter Roberson
Walter Roberson 2019년 4월 5일
So you are doing trapz() of the v array at the moment, but you feel it would be more accurate to do plain summation? If so why not just reshape v to have Tb*fs rows and sum along the first dimension ?
What reason do you have to expect plain summation to better represent the area than trapz ?

댓글을 달려면 로그인하십시오.

답변 (1개)

madhan ravi
madhan ravi 2019년 4월 3일
Perhaps you want to use cumtrapz() or trapz().
  댓글 수: 1
Willim
Willim 2019년 4월 4일
I have using it but It give me a wrong answer , and I believe the summing formula is going to be easirer.

댓글을 달려면 로그인하십시오.

카테고리

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