MATLAB: Neglecting certain values taken by the contour

contour plotting

I have a contour plot M whose values are ranging from positive to negative. On my output plot,I only want to show the values greater than or equal to 0 value of M
Ro=0.00:0.005:0.3;
Ri=real(((Ro.^4)-(Ro./(1250*pi))).^(0.25));
[a,b]=meshgrid(Ro,Ri);
M=39250.*pi.*((a.*a)-(b.*b));
%Delta=0.00992./b;
[C,h]=contour(a,b,M,30);
clabel(C,h);

Best Answer

I am not certain what you want to do, so I included two options for you to choose from:
Ro=0.00:0.005:0.3;
Ri=real(((Ro.^4)-(Ro./(1250*pi))).^(0.25));
[a,b]=meshgrid(Ro,Ri);
M=39250.*pi.*((a.*a)-(b.*b));
%Delta=0.00992./b;
[C,h]=contour(a,b,M,30);
Lvls = h.LevelList; % <— Add This Line
h.LevelList = Lvls(Lvls >= 0); % Only Plots Levels >= 0
clabel(C,h, Lvls(Lvls >= 0)); % Only Labels Levels >= 0