Surface integral calculation over a segment defined by two points
1 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(1 个)
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.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!