我已经成功获得了轮廓的线(或边缘),因此我得到了每条线的限制:
我想要的是对第二个图中外部蓝线内部的轮廓 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
作为曲线外部的点
关于matlab - 等值线图水平值的总和,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50172942/