need to write values on contour plots

조회 수: 2 (최근 30일)
danish ansari
danish ansari 2020년 10월 13일
답변: Sudhakar Shinde 2020년 10월 13일
i want to write the objective function value on the contours.
which functiona should i use?
as of now i am using this
---% part of a code--
fcontour(f)
hold on;
plot(x,y,'*-r');
it is giving a following contour lines with different colours which are the values of function "f". so how can i print the values of function in these lines (not red lines).
while f is the function of x &y.

답변 (2개)

Star Strider
Star Strider 2020년 10월 13일

Sudhakar Shinde
Sudhakar Shinde 2020년 10월 13일
these examples may help you:
%1
f = @(x,y) exp(-(x/3).^2-(y/3).^2) + exp(-(x+2).^2-(y+2).^2);
fc = fcontour(f);
fc.LineWidth = 1;
fc.LineStyle = '--';
fc.LevelList = [1 0.9 0.8 0.2 0.1];
colorbar
%2
figure
fcontour(@(x,y) x.*sin(y) - y.*cos(x), [-2*pi 2*pi], 'LineWidth', 2);
grid on
title({'xsin(y) - ycos(x)','-2\pi < x < 2\pi and -2\pi < y < 2\pi'})
xlabel('x')
ylabel('y')

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by