来自contourc数据的Matlab等高线图

问题描述 投票:0回答:1

如何在Matlab中,如何从轮廓数据生成等高线图,例如从countourc生成的等高线图? contour内部使用contourc将高程数据转换为轮廓数据;但是从文档中并不清楚我如何能够直接直接提供轮廓数据。

matlab contour
1个回答
0
投票

如果您使用的是旧版本的MATLAB,请尝试此操作

[C,h] = contour(peaks(30),-8:2:8);
h1 = get(h,'children');
X = get(h1,'xdata');
Y = get(h1,'ydata');
hold on
plot(X{5},Y{5},'.r')
hold off

这是2014年及以后的版本

[C,h] = contour(peaks(30),-8:2:8);
i = 1;
slev = 4;                           % draw specific level
hold on
while i < size(C,2)
    ncnt = C(2,i);                  % number of points for current contour
    if abs(C(1,i) - slev) < 0.01    % check if it's desired contour
        icnt = i+(1:ncnt);
        plot(C(1,icnt), C(2,icnt), '.r')
        break;
    end
    i = i + ncnt + 1;               % next contour
end
hold off
© www.soinside.com 2019 - 2024. All rights reserved.