필터 지우기
필터 지우기

Remove contour line from unwanted region

조회 수: 8 (최근 30일)
K3iTH
K3iTH 2021년 8월 23일
댓글: Wan Ji 2021년 8월 23일
Hi all, I am able to plot the contour at specific level. However, I want to remove/white out some contour lines from the unwanted region (between -1 to 1 for X and Z). I can create a white space for a 1D matrix (example from other user) with the code below but I have an issue with a matrix (360x180). The code below is not working for 2D matrix. I want to remove the all the contour line when X and Z is between -1 to 1. I have included my .mat file for X_2D,Z_2D and T_2D. Thank you for your kind response.
%%Example from other user
x = -100:100;
y = -100:100;
inputData = rand(201);
inputData(abs(x)<=10,abs(y)<=10) = nan;
contourf(x,y,inputData,'LineStyle','none');
%myCode
[M,c] = contour(X_2D,Z_2D,T_2D,1.025,'k');
c.LineWidth = 1;
xlabel('$x$','Interpreter','latex')
ylabel('$z$','Interpreter','latex')
axis equal
axis([-5 5 -5 5])
pbaspect([4 3 1])

채택된 답변

Wan Ji
Wan Ji 2021년 8월 23일
%%Example from other user
x = -100:100;
y = -100:100;
inputData = rand(201);
inputData(abs(x)<=10,abs(y)<=10) = nan;
contourf(x,y,inputData,'LineStyle','none');
% myCode
T_2D(abs(X_2D)<1 & abs(Z_2D)<1) = NaN; % remove the all the contour line when X and Z is between -1 to 1
[M,c] = contour(X_2D,Z_2D,T_2D,1.025,'k');
c.LineWidth = 1;
xlabel('$x$','Interpreter','latex')
ylabel('$z$','Interpreter','latex')
axis equal
axis([-5 5 -5 5])
pbaspect([4 3 1])
Then the result is shown as
  댓글 수: 2
K3iTH
K3iTH 2021년 8월 23일
Thanks Wan Ji. That is what I need. Appreciate your help!
Wan Ji
Wan Ji 2021년 8월 23일
My pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by