controlling the spread of contour lines
7 次查看(过去 30 天)
显示 更早的评论
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);
0 个评论
回答(1 个)
Star Strider
2018-11-9
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Contour Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!