필터 지우기
필터 지우기

Numerical integral at irregular intervals of scattered data

조회 수: 4 (최근 30일)
matnewbie
matnewbie 2015년 11월 17일
편집: matnewbie 2015년 11월 18일
I have two vectors x,y of equal size (for example 5000 elements), ranging from 0 to 1 (containing scattered data, but already sorted in increasing order). I want to evaluate the numerical integral of y(x) for each interval defined by the following vector [0 0.27 0.38 0.46 0.53 0.60 0.65 0.71 0.76 0.80 0.85 0.89 0.93 0.96 1] by means of trapz. How can I obtain the vector of evaluated integrals at each interval?

채택된 답변

Torsten
Torsten 2015년 11월 17일
First use cumtrapz for cumulated integration, then use interp1 to interpolate to your vector:
z=cumtrapz(x,y);
zinter=interp1(x,z,xinter);
where xinter=[0 0.27 0.38 0.46 0.53 0.60 0.65 0.71 0.76 0.80 0.85 0.89 0.93 0.96 1]
Best wishes
Torsten.
  댓글 수: 3
Torsten
Torsten 2015년 11월 17일
You wrote you already sorted x in increasing order...
Best wishes
Torsten.
matnewbie
matnewbie 2015년 11월 18일
편집: matnewbie 2015년 11월 18일
Thank you, but I posted a new question, since I am not interested anymore in irregular intervals.

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

추가 답변 (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