need to write values on contour plots
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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.
0 Kommentare
Antworten (2)
Sudhakar Shinde
am 13 Okt. 2020
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')
0 Kommentare
Siehe auch
Kategorien
Mehr zu Contour Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!