Understanding the working mechanism of contourc
Show older comments
could someone explain how contourc(x,y) works?
I am getting a 2xN array as a result but can not figure what are these numbers states for. If it is possible, could you write down the equivalent code for contourc without using any function similar to contourc.
Thanks a lot.
10 Comments
"could someone explain how contourc(x,y) works?"
As I recall, the algorithm used to be explained on some tech doc... but these are long gone.
But luckily for you I know that it was saved in the Internet Archive (scroll down to "The Contouring Algorithm"):
"I am getting a 2xN array as a result but can not figure what are these numbers states for"
The output matrix is explained here:
I agree that it is a very unhelpful output format.
You might like to use a wrapper function which returns a more useful and clearer output by downloading one of these:
"If it is possible, could you write down the equivalent code for contourc without using any function similar to contourc."
Kerem Yüksel
on 14 Nov 2023
Edited: Kerem Yüksel
on 14 Nov 2023
which -all contourc
We don't distribute the source code for built-in functions.
If the source code were available, what would you want to do with it? How would you hope to use that information?
If you want to know how the contour matrix is calculated, open contours(). It's old, but it should still be hanging around in plainly readable m-code.
%CONTOURS Contouring over non-rectangular surface.
% CONTOURS computes the contour matrix C for use by CONTOUR,
% CONTOUR3, or CONTOURF to draw the actual contour plot.
%
% CONTOURS(...) is the same as CONTOURC except CONTOURS(X, Y, Z, ...)
% allows the specification of parametric surfaces (as for SURF).
% ...
Oh jeez. I skimmed through it and didn't catch that. I just saw some polyline handling, didn't see the call to contourc(), and thought "this looks meaty enough".
I suppose it's just as well, since we apparently aren't allowed to use any functions that would create the contour matrix.
Kerem Yüksel
on 15 Nov 2023
Stephen23
on 15 Nov 2023
"How are these x and y values selected? I am working on the small arrays to understand the basics of the function but can not figure out."
The first link I gave you explains that:
Kerem Yüksel
on 15 Nov 2023
Kerem Yüksel
on 16 Nov 2023
Answers (1)
Categories
Find more on Contour Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!