Contour plot not working (but contour3 plot does work)
Show older comments
Hello everyone,
For some reason when I use the 'contour' function, it just gives me a blank figure. On the other hand, if I use 'contour3' it displays the 3-D contour plot. Any suggestions why this may be happening?
- Finally, I plot them and obtain the desired surface and mesh plots; but, I am unable to obtain the contour plot as I mentioned above.
Thank you in advance for any help provided.
Accepted Answer
More Answers (1)
Richard McCulloch
on 27 Jul 2013
0 votes
From my understanding, meshgrid will create a matrix out of x and y to provide a 2 dimensional indexing for z. To get a simple 2D contour the vectors have to be the same size. This is because you are essentially defining a z value at an ordered pair (x,y). If the data is linear maybe look at linspace to make them all the same length.
3 Comments
David (degtusmc)
on 29 Jul 2013
Richard McCulloch
on 29 Jul 2013
Is your Z a single value? I am getting it to work fine with this example:
x=[1:31]'; y=[1:19]'; z=rand(31,19);
size(x), size(y), size(z)
ans =
31 1
ans =
19 1
ans =
31 19
[x,y]=meshgrid(x,y);
contour(x,y,z')
contour3(x,y,z')
Are any errors showing up? This is a unique problem it seems.
Richard
David (degtusmc)
on 1 Aug 2013
Categories
Find more on Contour Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!