Why do CONTOUR and CONTOURC produce different results in MATLAB 7.8 (R2009a)?

6 views (last 30 days)
The CONTOURC documentation states that: "contourc calculates the contour matrix C used by contour, contour3, and contourf.". So I am wondering why the following code does not produce the same results for C1 and C2:
[C1,h] = contour(peaks)
C2 = contourc(peaks)

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
When using CONTOUR and CONTOURC the results C1 and C2 might indeed differ:
[C1,h] = contour(peaks)
C2 = contour(peaks)
However C1 and C2 are not necessarily expected to be exactly the same. As of MATLAB 7.4 (R2009a) the CONTOUR documentation provides the following explanation:
[C,h] = contour(...) returns a contour matrix, C, derived from the matrix returned by the low-level contourc function, and a handle, h, to a contourgroup object. clabel uses the contour matrix C to create the labels. (See descriptions of contourgroup properties.)
In this context "derived" indicates the matrices are not exactly the same, which is due to numerical precision as well as post-processing that occurs in CONTOUR. The same holds true for the sentence: "contourc calculates the contour matrix C used by contour".

More Answers (0)

Categories

Find more on Contour Plots in Help Center and File Exchange

Products


Release

R2009a

Community Treasure Hunt

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

Start Hunting!