필터 지우기
필터 지우기

How to integrate using trapz function

조회 수: 5 (최근 30일)
shagun chaudhary
shagun chaudhary 2022년 8월 31일
댓글: Bjorn Gustavsson 2022년 8월 31일
Hi I am using trapz to get my answer. but i am getting 0 which is not the answer. I have attched my data where Y reprsesnt loads (mg/hr) and x represents time in a number form . Please i will extremely graeful if somebody can help.
Int=trapz(X1,Y);

채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2022년 8월 31일
The variable in X1 seems awfully constant, at 0.0166. The first input to trapz should be the x-coordinate of the points at which you have Y, not the values of "dx". Perhaps what you want is something like:
Ival = trapz(cumsum(X1),Y);
HTH
  댓글 수: 4
shagun chaudhary
shagun chaudhary 2022년 8월 31일
How to get Trapz for all 56 combination. This is what ineed. Thanks
Bjorn Gustavsson
Bjorn Gustavsson 2022년 8월 31일
If you look at the help for trapz you will read:
Z = trapz(X,Y,DIM) or trapz(Y,DIM) integrates across dimension DIM
of Y. The length of X must be the same as size(Y,DIM)).
That means that your call to trapz would be something like:
z_all = trapz(cumsum(X1),Y,2);

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

추가 답변 (0개)

카테고리

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