Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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

share|improve this question
    
Haha I saw this post and thought, "that's something Trevor would work on." I guess I was right! –  Joel Jul 6 '13 at 17:15
1  
Did you intend $\{z\in\mathbb{C}:|p(z)|=2\}$ etc? –  Tpofofn Jul 6 '13 at 17:35
    
@Tpofofn Yes of course. Thanks, I made the edit. –  Trevor Jul 6 '13 at 19:13
    
@Joel You were right. Small world. –  Trevor Jul 6 '13 at 19:14

2 Answers 2

up vote 3 down vote accepted

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.

share|improve this answer

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

share|improve this answer
    
Thanks, I will give it a try. –  Trevor Jul 6 '13 at 19:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.