matlab中轮廓曲面下的体积

时间:2021-01-11 15:00:12

I am using contourf to generate a contour plot for a 2 variable function.

我使用contourf生成2变量函数的等高线图。

My function is Z = f(x,y).

我的函数是Z = f(x,y)。

I generate x and y through meshgrid function in matlab and generate values for Z and then plot the contour using contour(x,y,z).

我通过matlab中的meshgrid函数生成x和y,并为Z生成值,然后使用轮廓(x,y,z)绘制轮廓。

I want to be able to calculate the volume under this generated contour. Can anyone please help ?

我希望能够在这个生成的轮廓下计算体积。有人可以帮忙吗?

Thanks in advance

提前致谢

1 个解决方案

#1


couldn't you simply use a integral approximation like a riemann sum? Assuming uniform spacing for x and y something like this should work

难道你不能简单地使用像黎曼和的积分近似吗?假设x和y的间距均匀,这样的事情应该有效

delta_x = x(2) - x(1);
delta_y = y(2) - y(1);
vol = sum(Z(:)) * delta_x * delta_y;

This will not be the EXACT volume, but an approximation. Since you know your function you would get a more accurate answer by performing the integration of the function. But if you did not know the function you would use this method or any other numerical integration method.

这不是精确的音量,而是近似值。由于您了解自己的功能,因此您可以通过执行功能集成获得更准确的答案。但是,如果您不知道该函数,您将使用此方法或任何其他数值积分方法。

From calculus we know that an actual integral is just a reimann sum where the width of each interval is infinitely small, so this should be a valid approximation

从微积分我们知道实际积分只是一个reimann和,每个区间的宽度无限小,所以这应该是一个有效的近似值

#1


couldn't you simply use a integral approximation like a riemann sum? Assuming uniform spacing for x and y something like this should work

难道你不能简单地使用像黎曼和的积分近似吗?假设x和y的间距均匀,这样的事情应该有效

delta_x = x(2) - x(1);
delta_y = y(2) - y(1);
vol = sum(Z(:)) * delta_x * delta_y;

This will not be the EXACT volume, but an approximation. Since you know your function you would get a more accurate answer by performing the integration of the function. But if you did not know the function you would use this method or any other numerical integration method.

这不是精确的音量,而是近似值。由于您了解自己的功能,因此您可以通过执行功能集成获得更准确的答案。但是,如果您不知道该函数,您将使用此方法或任何其他数值积分方法。

From calculus we know that an actual integral is just a reimann sum where the width of each interval is infinitely small, so this should be a valid approximation

从微积分我们知道实际积分只是一个reimann和,每个区间的宽度无限小,所以这应该是一个有效的近似值