-1

This is my code:

syms x y;
f= x^2/(y-y^2);
ezcontour(f,[-1,1],[0.1,0.9]);

How can i show the labels? I wan to show something like this: ContourLinesExample

Thank You very much!

Community
  • 1
  • 1
Motoralfa
  • 450
  • 3
  • 10

2 Answers2

1

Using contour :

x = [-1:0.01:1];
y = [0.1:0.01:0.9];
[X, Y] = meshgrid(x,y);
f= X.^2./(Y-Y.^2);
[C, h] = contour(f);
clabel(C, h);

contour

Zeta.Investigator
  • 911
  • 2
  • 14
  • 31
0

clabel wants as an input the contour matrix being displayed by the Contour object. While ezcontour doesn't return the matrix like contour does, the Contour object has a 'ContourMatrix' property. If you specify an output for ezcontour it will return the handle to the plotted contour that can be queried directly.

For example:

f = @(x, y) x.^2/(y-y.^2);

h = ezcontour(f, [-1, 1], [0.1, 0.9]);
C = h.ContourMatrix;  % R2014b or newer
% C = get(h, 'ContourMatrix');  % R2014a and older
clabel(C, h);

Returns the desired output:

yay

Alternatively, you can can just pass the handle to the contour to obtain the same result:

clabel([], h);

Per the documentation:

If you do not have the contour matrix C, then replace C with [].

sco1
  • 12,154
  • 5
  • 26
  • 48