Number of line for fcontour

5 ビュー (過去 30 日間)
David Togonidze
David Togonidze 2021 年 11 月 26 日
回答済み: Star Strider 2021 年 11 月 27 日
If somebody can tell me how to increase number of lines for fcontour plot I would be much grateful. Thanks in advance.

採用された回答

Star Strider
Star Strider 2021 年 11 月 27 日
A somewhat different approach —
syms x y
z(x,y) = exp(-(x-5)^2) + cos(y)
z(x, y) = 
figure
hfc = fcontour(z, [0 10 -2*pi 2*pi]);
colormap(turbo)
title('Default Levels')
figure
hfc = fcontour(z, [0 10 -2*pi 2*pi]);
Lvls = hfc.LevelList;
hfc.LevelList = linspace(min(Lvls), max(Lvls), 5*numel(Lvls));
colormap(turbo)
title('Increased Countours, Same Range')
.

その他の回答 (1 件)

Image Analyst
Image Analyst 2021 年 11 月 26 日
Look at the max and min of your surface, then compute the 'LevelStep' using the number of contours you want. Something like (untested)
numContours = 10;
levelStep = (max(z(:)) - min(z(:))) / numContours;
fcontour(z, 'LevelStep', levelStep);
  1 件のコメント
David Togonidze
David Togonidze 2021 年 11 月 26 日
It gives me the error about levelStep not being a double which is logical since I have symbolic expressions in "Z". Shoud have mentioned that in the original question.

サインインしてコメントする。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by