How to plot contour plot with NaN in matrix ?
Afficher commentaires plus anciens
I have three matrices xvalues (X), yvalues (Y) and measured property (Z). All these three are upper triangular matrices with lower triangular part containing NaN values. How do I plot a contour plot only for the upper triangular part?
Réponses (1)
Star Strider
le 10 Déc 2014
Modifié(e) : Star Strider
le 10 Déc 2014
0 votes
If you plotted it as it currently exists, the NaN values would simply not plot anything, that is be blank areas of the contour plot.
8 commentaires
Karthik
le 10 Déc 2014
Star Strider
le 10 Déc 2014
Then keep it as it is with the NaN values. The NaN values will not plot, leaving that part of the plot blank.
Karthik
le 12 Déc 2014
Star Strider
le 12 Déc 2014
Karthik
le 12 Déc 2014
Star Strider
le 12 Déc 2014
My pleasure.
I don’t have your data, so I’ve been simulating them with this code:
M = magic(10);
Mtu = triu(M);
Mtu(Mtu==0) = NaN;
figure(1)
contourf(Mtu)
This works. The other option you might consider is to increase the number of contour lines, for instance:
contourf(Mtu,50)
Star Strider
le 12 Déc 2014
I have no idea what you’re doing, but you can see what the result is if you replace the contourf plot with surfc:
surfc(X,Y,Z)
To see only ‘Z’:
surfc(Z)
The problems with ‘X’ and ‘Y’ can be seen if you plot them:
surfc(X)
surfc(Y)
The point is that ‘X’ and ‘Y’ are not linear, and ‘Z’ seems not to exist along the diagonal.
I’ll leave you to sort these. The plotting is trivial once you deal with whatever is going on with your data.
Catégories
En savoir plus sur Contour Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!