Filling a region in the complex plane in Matlab

조회 수: 14(최근 30일)
Abdullah Md Saifee 2020년 10월 10일
답변: Walter Roberson 2020년 10월 11일
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

댓글을 달려면 로그인하십시오.

답변(2개)

Stanislao Pinzón 2020년 10월 11일
Maybe something like this:
f1=@(x,y) (1+x+x.^2-y.^2).^2+(y+2.*x.*y).^2-1;
V = fimplicit(f1);
hold on
axis([-1.5 0.5 -1.5 1.5])
xlabel('Re(h\lambda)')
ylabel('Im(h\lambda)')
fill(V.XData,V.YData,'r')
댓글 수: 0표시숨기기 이전 댓글 수: -1

댓글을 달려면 로그인하십시오.

Walter Roberson 2020년 10월 11일
This turns out to be a bit tricky.
If you record the handle
h = fimplicit(f1);
then h.XData, h.YData are the vertex lists. The vertex lists are also available in several other places inside of h.
However... the XData, YData both have embedded NaN. It looks as if each place that the function has a major change in curvature, a different nan-separated group of vertices is started.
Now, you might expect "Okay, just delete the nan out of the vertex lists!", but it turns out that the groups are not in sequence, and also that there are definite gaps between the pieces.
Often, using boundary() can be used to adapt between a set of points and a continuous line, but boundary() does not get the (concave) indentations right.
I was not able to find any properties (including hidden ones) that indicated how the segments should be joined, or what order the segments should be in.
Notice the obvious gaps.
So although it appears to be possible to get the information about the discontinuous segments, interpreting the segment information is tricky.
I have not investigated the representation for the case where there is a real discontinuity in the plot, such as cases where the implicit plot should be two elipses.

댓글을 달려면 로그인하십시오.

범주

Find more on Graphics Performance in Help Center and File Exchange

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by