Effacer les filtres
Effacer les filtres

controlling the spread of contour lines

7 vues (au cours des 30 derniers jours)
ANOSH PHIROZ AMARIA
ANOSH PHIROZ AMARIA le 9 Nov 2018
I have the following code which plots a filled contour. I want more closed contours towards the center of the figure because they are more important to me. How can I control the spacing of the contour lines?
% Function to plot contours
x1=-5:0.1:5;
x2=-5:0.1:5;
[a ,b]=meshgrid(x1,x2);
f=(2.*(a).^2)-(1.05.*(a).^4)+((a.^6)./6)+(a.*b)+(b.^2);
[c,h]=contourf(a,b,f,20);
clabel(c,h);

Réponses (1)

Star Strider
Star Strider le 9 Nov 2018
You can define the contour levels with a vector.
Example
% Function to plot contours
x1=-5:0.1:5;
x2=-5:0.1:5;
[a ,b]=meshgrid(x1,x2);
f=(2.*(a).^2)-(1.05.*(a).^4)+((a.^6)./6)+(a.*b)+(b.^2);
lvls = exp(-10:0.1:7.5); % Define Contour Levels
[c,h]=contourf(a,b,f,lvls);
clabel(c,h);
The ‘lvls’ vector creates an exponentially-increasing set of contours. You can use any vector you want.

Catégories

En savoir plus sur Contour Plots dans Help Center et File Exchange

Tags

Produits


Version

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by