matlab - 等高线图中水平值的总和
问题描述
我设法获得了轮廓的线条(或边缘),所以我有每条线的限制:
我想要的是对第二个图中外蓝线内的轮廓 z 轴上的所有级别求和,以将其与蓝线外的值的总和进行比较。有没有办法做到这一点?我到目前为止的代码是:
C = contourc(f, t, abs(tfr));
%extracts info from contour
sz = size(C,2); % Size of the contour matrix c
ii = 1; % Index to keep track of current location
jj = 1; % Counter to keep track of # of contour lines
while ii < sz % While we haven't exhausted the array
n = C(2,ii); % How many points in this contour?
s(jj).v = C(1,ii); % Value of the contour
s(jj).x = C(1,ii+1:ii+n); % X coordinates
s(jj).y = C(2,ii+1:ii+n); % Y coordinates
ii = ii + n + 1; % Skip ahead to next contour line
jj = jj + 1; % Increment number of contours
end
解决方案
因此,在您运行问题中的代码后,您将获得数组中每个轮廓的坐标S
。假设你有变量f
和t
形式f = 94:0.1:101
和t = 0:1000
或类似的,你想求和的那个值是abs(tfr)
你应该能够使用的
[fg, tg] = meshgrid(f,t)
is_inside = inpolygon(fg,tg, S(1).x, S(1).y)
integral = sum(abs(tfr(is_inside))
对于S
. 有关更多示例,请参阅inpolygon的帮助。您可以~is_inside
用于曲线外的点
推荐阅读
- python - gurobi中的对数约束
- c - libwebsocket 不在已建立的连接上发送数据包
- javascript - 迭代原始数组时如何将“真”结果返回到新数组?
- javascript - 未捕获的 TypeError:this._triggerEvent 不是 jQuery SmartCart 中的函数
- php - 是否可以在一维数组中获取所有 XML 数据?
- android - 与 viewPager 一起使用时,recyclerView 不显示数据
- delphi - Delphi IDE Expert - 拦截“查看源代码”或 DPR 文件加载
- php - 在 PHP 没有密码提示的情况下执行 samba 挂载命令?
- php - 替换 cakephp 3 查询中其他静态词的空或空响应
- c++ - inline 关键字可以改变函数的行为吗?