1
votes

I have this plot that I generated as a test of figuring out how contour plots work on matlab in general. I'm trying to figure out if there is a way I can plot just one of the lines but not necessarily the first line.

They way Matlab explains it is if you do:

 contour(X,Y,Z,1);

it will plot one of the lines but it's always the first one, but for my particular case I want the 3rd or 4th one. Is there a way to do that in Matlab?

1
What do you mean by "the first line"? If you want to plot the contour at a particular value you have to use a two element vector with the desired value twice: v = [2 2]; contour(X,Y,Z,v) Will plot the contour at value 2 - user1337

1 Answers

4
votes

contour(Z,N) and contour(X,Y,Z,N) draw N contour lines, choosing the levels automatically. This is not what you want!

contour(Z,V) and contour(X,Y,Z,V) draw a contour line for each level specified in vector V. Use contour(Z,[v v]) or contour(X,Y,Z,[v v]) to draw contours for the single level v.

Suggesting the levels of the 3rd and 4th line are 7 and 8 you have to write contour(X,Y,Z,[7 7]) to only plot the 3rd line or contour(X,Y,Z,[7 8]) to plot the 3rd and the 4th line.