Surface integral calculation over a segment defined by two points

조회 수: 3 (최근 30일)
Riccardo Giaffreda
Riccardo Giaffreda 2020년 1월 23일
답변: Walter Roberson 2020년 1월 24일
Hello, I have generated two vectors x=y=[-50:50] then a map with the meshgrid command. Then I have generated some random points that I have interpolated with command griddata in order to get the z values in corrispondace of the coordinates x,y of the map. My problem is that, given two points x1,y1 and x2,y2 I want to calculate the sum of the z values I get over the segment defined by this two points. Since it might be that the segment goes over points that are not pure integer I cannot do it..(I do not have a shape that I can describe in close form).. How can I solve the problem?

답변 (1개)

Walter Roberson
Walter Roberson 2020년 1월 24일
Xq=linspace x1 to x2 and Yq=linspace y1 to y2, using the same number of steps. Now use those as the query locations in an interp2 call.
sqrt((X2-X1)^2 + (Y2-Y1)^2) / number of steps
to get the distance between adjacent points which you need as the second parameter to trapz() to estimate the area.

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by