Confused about syntax of contour function
Show older comments
My task is very similar as to in this question - in that I have data in the form of X,Y,Z triplets and I want to find the X,Y pairs for which Z=0.
In the answer, it is stated that the zero contour can be plotted using:
[c, hc] = contour(x,y,z,[0 0],'k');
Looking at the help documents, this is one of several pieces of syntax for the function and returns the contour matrix, c, and the contour object, hc.
I get that the former holds the contour defining data.
- What is the latter - the contour object?
- [c, hc] suggests to me an array/vector. Why is this being used?
Furthermore, considering the arguments of the contour function call. If I am reading the documentation correctly:
- the first three - x, y, z - relate to the data being considered;
- the [0,0] argument of the contour function call is specifying the level of the contour - so here Z=0. Why is the number repeated? If I want the contour at level 5, do I change this argument to [5,5]?
- What does the 'k' do?
Finally, is it possible to plot the contour as a serious of markers rather than a line?
Accepted Answer
More Answers (1)
John D'Errico
on 11 Dec 2015
0 votes
Note that you claim to have data in the form of scattered triplets, (x,y,z). Contour does NOT solve this problem. That is generally known as scattered data.
However, there are several tools for contouring scattered data on the file exchange. Do a search for "tricontour" on the FEX and you should find at least two tools up there.
2 Comments
Giles_T_R_Abbbit
on 12 Dec 2015
John D'Errico
on 12 Dec 2015
If your data is really just an unrolled rectangular array, then reshape will suffice, as you appear to have found.
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!