Hello, I have been trying to understand what the contour levels are.
Matlab docs state that the contourc function takes an argument that determines the levels of which the contours are computed upon, and I have been playing around with the parameter in hope of recognising what they really represent but I honestly cannot get a grip on that.
I will be so grateful if someone could clue me in.
Thank you all,

回答 (1 件)

John D'Errico
John D'Errico 2018 年 10 月 11 日

0 投票

A contour of the function z(x,y) is a set of points in the (x,y) plane, such that z(x,y) is fixed at some constant value. That constant value is the contour "level". That set of points in the (x,y) plane is often called a level set.
contour (as well as contourc) allow you to supply specific levels if you are interested in some specific value for z, or you can just tell it a number n (an integer). In that case, contour generates n levels between the min and max of the function over the domain of interest.

2 件のコメント

Nour Eddin Ramadan
Nour Eddin Ramadan 2018 年 10 月 12 日
Thank you, that was helpful.
Nour Eddin Ramadan
Nour Eddin Ramadan 2018 年 10 月 12 日
編集済み: Nour Eddin Ramadan 2018 年 10 月 12 日
I wanted to try that out, so I constructed a picture with 10 rectangles, each of which has a distinct depth starting from 0.1 ending up at 1.0, and I ran the contour function to see the highlighted contours according to the specified levels in the input, but the results weren't expected.
For instance, I ran the code on 0.1 contour level and the contour function produces all the contours in the picture, not only the ones with 0.1 level.
Code:
pic = zeros(500, 500);
val = 0.1;
shift = 40;
for j = 1:10
for i= 50:450
pic(shift*j,i) = val;
end
for i= 50:450
pic(shift*j+25,i) = val;
end
for i = shift*j: shift*j+25
pic(i, 50) = val;
pic(i,450) = val;
end
val = val + 0.1;
end
imshow(pic);
figure(2);
contour(pic, [0.1 0.1]);
Did I not get what you meant or am I doing something wrong here?
Thanks in advance,

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeContour Plots についてさらに検索

製品

リリース

R2018a

質問済み:

2018 年 10 月 11 日

編集済み:

2018 年 10 月 12 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by