Why Contour matrix M ( [M,c] = contour(__) ) contains the data points exceeding xmax/ymax?

조회 수: 3 (최근 30일)
I have a contour plot (fig 1), plotted according to [M,h]=contourf(f,8). With this I slice contour #8. Thus, I expect to have in matrix M all (x,y) coordinates of the 8th contour. These coordinates have (logically) not to exceed the xmax/ymax (250/250). Instead, when I plot matrix M i have some values that larger then xmax/ymax (figure 2). According to the documentation (https://de.mathworks.com/help/matlab/ref/contour.html#mw_27139ced-212f-437f-abab-0ff7c175e33b),
the first pair of data is the Level and the number of Vertices. But plotting the contour(f,8) in Fig1 I should have only first pair of data in returned M which describe the leve 8 l!!!
Please explain their origin of larger data.
Figure 1
Figure 2 (Plotted M)
  댓글 수: 6
Stephen23
Stephen23 2021년 3월 2일
"how the automatically determined height correlats with the min, max values of input Z????"
I have no idea: the documentation only states "automatically", it does not give an algorithm. But if you are interested:
  • search this forum for other discussions on this topic.
  • use the internet archive to see if previous versions of the documentation included information on the algorithm.
Sergii Snegir
Sergii Snegir 2021년 3월 2일
many thanks. The documentation about Matlab is very unclear sometimes, I need to say.
Have a nice evening.

댓글을 달려면 로그인하십시오.

채택된 답변

Bruno Luong
Bruno Luong 2021년 3월 2일
편집: Bruno Luong 2021년 3월 2일
[M,h]=contourf(f,8)
Return contours of 8 levels, not single level of value 8.
  댓글 수: 2
Sergii Snegir
Sergii Snegir 2021년 3월 2일
Dear Bruno. Sorry for dump question, but can you please explain what does mean n= 8 levels if I see on the figure1 one contour? I read one more time documentation, and can not get. I thought that "levels", means height of f, and thus, I slice from the top n=1 to the lower levels n=8.
Bruno Luong
Bruno Luong 2021년 3월 2일
편집: Bruno Luong 2021년 3월 2일
The doc
"Use this argument to control the number and location of the contour lines. When you do not specify the levels, the contour function chooses the levels automatically.
  • To draw contour lines at n automatically chosen heights, specify levels as the scalar value n.
  • To draw the contour lines at specific heights, specify levels as a vector of monotonically increasing values.
  • To draw contour lines at a single height k, specify levels as a two-element row vector [k k]."
I don't know what *you* see on your image, if I do this
f=peaks;
[M,h]=contourf(f,8)
I get this contour plot like there are 8 "heights" to me (counted from bright yellow to dark blue):

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by