Effacer les filtres
Effacer les filtres

Surface integral calculation over a segment defined by two points

5 vues (au cours des 30 derniers jours)
Riccardo Giaffreda
Riccardo Giaffreda le 23 Jan 2020
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?

Réponses (1)

Walter Roberson
Walter Roberson le 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.

Catégories

En savoir plus sur Numerical Integration and Differentiation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by