首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在面积或体积上对不均匀采样函数进行数值积分

在面积或体积上对不均匀采样函数进行数值积分
EN

Stack Overflow用户
提问于 2013-08-21 15:59:00
回答 1查看 583关注 0票数 1

从一些有限元建模软件中,我得到了一些函数在三维体积上的价值.我想把这个函数的值与卷的值结合起来。麻烦的是,从FEM软件导出的数据并没有定义规则网格上的函数,而是定义了对应于有限元软件所使用的(不均匀)网格的点集合(x、y、z)。

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

EN

回答 1

Stack Overflow用户

发布于 2013-08-21 15:59:46

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

代码语言:javascript
运行
复制
% 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;

但还有更好的方法吗?

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18362286

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档