how can i contour level control use with 'plot'

I want Contour level control in my code
I know how to control the basic contour level,
I don't know contour level control with 'plot' and 'fit' code
how to 'Contour' level control? please teach me (Make the contour spacing more detailed.)
and i want specific number of contour values can be printed out(contour <0 or contour>0)
Please explain it with a picture
x=[1200 1200 1200 1200 1100 1100 1100 1100 1000 1000 1000 1000 900 900 900 900]';
y=[-2 -1 0 1 -2 -1 0 1 -2 -1 0 1 -2 -1 0 1]';
z=[0.577605826 0.488558387 0.45273093 0.478115298 0.547461689 0.460354119 0.420345944 0.43529964 0.497821842 0.370804822 0.305371971 0.318197107 0.416543949 0.372316357 0.339559983 0.319807786]';
f = fit( [x, y], z, 'cubicinterp' )
Piecewise cubic interpolant: f(x,y) = piecewise cubic surface computed from p Coefficients: p = coefficient structure
ph = plot(f, 'Style', 'Contour');
set(ph, 'Fill', 'off', 'LineColor', 'auto');
grid off;
C = get(ph, 'ContourMatrix');
clabel(C, ph);

 采纳的回答

You can set the LevelList property
x=[1200 1200 1200 1200 1100 1100 1100 1100 1000 1000 1000 1000 900 900 900 900]';
y=[-2 -1 0 1 -2 -1 0 1 -2 -1 0 1 -2 -1 0 1]';
z=[0.577605826 0.488558387 0.45273093 0.478115298 0.547461689 0.460354119 0.420345944 0.43529964 0.497821842 0.370804822 0.305371971 0.318197107 0.416543949 0.372316357 0.339559983 0.319807786]';
f = fit( [x, y], z, 'cubicinterp' );
ph = plot(f, 'Style', 'Contour');
set(ph, 'Fill', 'off', 'LineColor', 'auto');
ph.LevelList = linspace(0.2,0.6,20); % just pick some levels
grid off;
C = get(ph, 'ContourMatrix');
clabel(C, ph);

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Contour Plots 的更多信息

产品

版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by