【问题标题】:Numerically integrating an unevenly sampled function over area or volume在面积或体积上对不均匀采样的函数进行数值积分
【发布时间】:2013-08-24 02:41:06
【问题描述】:

从一些有限元建模软件中,我得到了某个函数在三维体积上的值。我想将这个函数的价值整合到音量上。问题是从 FEM 软件导出的数据没有在规则网格上定义函数,而是在与 FEM 软件使用的(不均匀)网格对应的点 (x,y,z) 集合上定义。

如何在 Matlab 中完成这种集成?

【问题讨论】:

  • 这取决于你的数据结构,但是如果你有一个四面体网格并且在节点处给出了值,你正在处理分段线性函数并且只需要使用中点规则:对于每个四面体计算体积;计算四面体节点的平均值,将这两者相乘以获得单个元素的积分,然后在整个网格上求和。

标签: matlab interpolation numerical-methods numerical-integration


【解决方案1】:

一种方法是使用TriScatteredInterp 将函数重新采样到常规网格上:

% Suppose f gives values of the function at points (x,y,z)
% Here we will resample f onto a regular grid.

% Define the x, y, and z axis vectors for the new grid.
xg = linspace(min(x), max(x), 100);
yg = linspace(min(y), max(y), 100);
zg = linspace(min(z), max(z), 100);

% Define the new grid
[Xg, Yg, Zg] = meshgrid(xg, yg, zg);

% Define an interpolator for the sampled function
F = TriScatteredInterp(x, y, z, f);
Fg = F(Xg, Yg, Zg);

% Now we have the function sampled on a regular grid and can use the
% traditional matlab techniques.

dx = xg(2) - xg(1);
dy = yg(2) - yg(1);
dz = zg(2) - zg(1);

my_integral = sum(sum(sum(Fg))) * dx*dy*dz;

但是有更好的方法吗?

【讨论】:

    猜你喜欢
    • 2011-07-21
    • 1970-01-01
    • 1970-01-01
    • 2016-12-13
    • 2016-01-12
    • 2023-03-17
    • 2014-07-19
    • 2021-11-30
    • 2013-12-16
    相关资源
    最近更新 更多