Clear Filters
Clear Filters

Surface integral calculation over a segment defined by two points

1 view (last 30 days)
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?

Answers (1)

Walter Roberson
Walter Roberson on 24 Jan 2020
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.

Categories

Find more on Interpolation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!