contour Plot Problems - Multiple wrong lines created
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi everybody,
I have some problems with contour plot. The problem is very clear: running the following code, I do get additional lines to what I would like to expect (I get lines also for x=[4.33, 4.66, 6.33, 6.66]).
I would like to have the lines only for E>0;
Thanks in advance, Alberto
clc;
clear all;
close all;
E=[0 0.01 0.02 0.03 0 0 0.03 0.02 0.01 0;
0 0.01 0.02 0.03 0 0 0.03 0.02 0.01 0;
0 0.01 0.02 0.03 0 0 0.03 0.02 0.01 0;
0 0.01 0.02 0.03 0 0 0.03 0.02 0.01 0;
0 0.01 0.02 0.03 0 0 0.03 0.02 0.01 0;
0 0.01 0.02 0.03 0 0 0.03 0.02 0.01 0;
0 0.01 0.02 0.03 0 0 0.03 0.02 0.01 0;
0 0.01 0.02 0.03 0 0 0.03 0.02 0.01 0;
0 0.01 0.02 0.03 0 0 0.03 0.02 0.01 0;
0 0.01 0.02 0.03 0 0 0.03 0.02 0.01 0];
contour(1:size(E,1),1:size(E,2),E,0.01:0.01:max(E(:)),'linecolor','k')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/162038/image.jpeg)
0 Commenti
Risposte (1)
Eeshan Mitra
il 29 Mar 2017
The additional lines at x=[4.33, 4.66, 6.33, 6.66] represent those locations where the values of E are predicted to be 0.02, 0.01, 0.01, and 0.02, respectively. Please note that contour will interpret a continuous transition from 0.03 at x=4, to 0 at x=5, and not an instantaneous change.
As pointed out within the documentation link above, NaN values in the desirable ranges may be used to model discontinuities.
Note: You'll need to use the sizes of columns and rows for X and Y, respectively, within the contour command. The code presented above works only because the number of rows and columns are equal, which changes when NaN values are added. Instead, you should use:
contour(1:size(E,2),1:size(E,1),E,0.01:0.01:max(E(:)),'linecolor','k')
0 Commenti
Vedere anche
Categorie
Scopri di più su Contour Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!