Filling a region in the complex plane in Matlab

$\begingroup$

So I have plotted the the function defined implicitly by fimplicit in Matlab. I want to fill the region inside. How to do that?

f1=@(x,y) (1+x+x.^2-y.^2).^2+(y+2.*x.*y).^2-1;
fimplicit(f1)
hold on
axis([-1.5 0.5 -1.5 1.5])
xlabel('Re(h\lambda)')
ylabel('Im(h\lambda)')
hold off

enter image description here

$\endgroup$

1 Answer

$\begingroup$

Here is a Matlab program which does the job:

clear all;close all;hold on
axis([-1.5 0.5 -1.5 1.5])
e=ezplot('(1+x+x^2-y^2).^2+(y+2*x*y)^2-1');
t=get(e,'ContourMatrix')
fill(t(1,2:end),t(2,2:end),'r')

Please note:

  • that I have used easyplot ("ezplot") instead of your (perfectly good) definition of function, because I am using an old release...

  • The presence of function "fill" (instead of "plot"). Take care: the first element contains size information in its first entry ; this is why we use the array of coordinates $t$ from $2$ to "end".

$\endgroup$

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like