Contour plot not working (but contour3 plot does work)
Mostra commenti meno recenti
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.
Risposta accettata
Più risposte (1)
Richard McCulloch
il 27 Lug 2013
0 voti
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 Commenti
David (degtusmc)
il 29 Lug 2013
Richard McCulloch
il 29 Lug 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)
il 1 Ago 2013
Categorie
Scopri di più su Contour Plots in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!