Remove contour line from unwanted region

7 views (last 30 days)
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])

Accepted Answer

Wan Ji
Wan Ji on 23 Aug 2021
%%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 Comments
K3iTH
K3iTH on 23 Aug 2021
Thanks Wan Ji. That is what I need. Appreciate your help!

Sign in to comment.

More Answers (0)

Categories

Find more on Contour Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!