필터 지우기
필터 지우기

How to show only elliptic region in color?

조회 수: 1 (최근 30일)
Abdul Mannan
Abdul Mannan 2020년 2월 21일
댓글: darova 2020년 2월 24일
Dear experts,
How can I get a plot like below in which no color will be shown outside of the ellipse?
If I use pcolor and I get a surface like below where outside of larger ellipse is filled with blue color that I don’t want.
A part of my code is given here.
pcolor(x1, y1, SS);
colormap jet
colorbar
hold on
quiver(x, y, sx, sy,'k'); % plot vector
hold on
x2 = x(TT > 0);
y2 = y(TT > 0);
ff2 = boundary(x2, y2);
plot(x2(ff2), y2(ff2),'r'); % plot outer boundary line
hold on
x3 = x(TT>0 & SS == 0);
y3 = y(TT>0 & SS == 0);
ff3 = boundary(x3, y3);
hold on
plot(x3(ff3), y3(ff3), 'r') % plot inner boundary line
Thanks in advanced.

채택된 답변

darova
darova 2020년 2월 21일
try this
[X,Y] = meshgrid( -10:0.2:10 );
Z = X.^2 + Y.^2;
ind = X.^2/5^2 + Y.^2/3^2 < 1;
Z(~ind) = nan;
pcolor(X,Y,Z)
  댓글 수: 7
Abdul Mannan
Abdul Mannan 2020년 2월 24일
Yes, your technique works. Thanks.
darova
darova 2020년 2월 24일
You can accept my answer so i could be happier

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by