Creating image in matlab with specified level sets of a complex polynomial.

1.4k Views Asked by At

I am trying to create an image in matlab which contains specified level sets for a complex polynomial. Suppose, for example, I wanted to create an image containing the sets $\{z\in\mathbb{C}:|p(z)|=2\}$, $\{z\in\mathbb{C}:|p(z)|=5\}$, $\{z\in\mathbb{C}:|p(z)|=9.5\}$. Could someone help me out with the code for this? Thanks

2

There are 2 best solutions below

0
On BEST ANSWER

Taking the Benice equation example from @Joel's answer, in Matlab this can be done simply via the builtin contour or the lower-level contourc functions:

f = @(x,y)(x.^2+y.^2-3).*sqrt(x.^2+y.^2)+0.75+ ...
    sin(8*sqrt(x.^2+y.^2)).*cos(6*atan(y./abs(x))) ...
    -0.75*sin(5*atan(y./abs(x)));
x = -2:0.01:2;       % x- and y- range, here y = x
[X,Y] = meshgrid(x); % Create mesh, here Y = X.'
Z = f(X,Y);          % Value of Benice equation at mesh points
v = [0 2];           % Heights/values of level set(s) to plot
contour(x,x,Z,v);    % Plot level set(s)
axis equal

As the help/documentation points out, the key is the fourth argument to contour and contourc functions, v. If you want plot just one level set, w, then you must set v = [w w].

More on creating contour plots with Matlab.

1
On

Not exactly Matlab, but gnuplot is a free professional graphing utility that can graph level curves, and produce figures appropriate for latex.

Here is a link with some code for a level curve:

http://benice-equation.blogspot.com/2011/07/gnuplot-example-plotting-implicit.html